Question
Asked by:
justanotherguy
justanotherguy
Rating : No Rating
Questions Asked: 3
Tutorials Posted: 0
 

$25.00 Java (Classes: Constructors/Accessing Class Members )

Q:

1.Suppose you are given the following main method:

public class BookWork {

public static void main() {
BoxOfBooks b = new BoxOfBooks(43,70.3);
System.out.println("There are " + b.getCount() + " books.");
System.out.println("They weigh " + b.getWeight() + " pounds.");
}
}


This is one example of how to use the BoxOfBooks class. Running the main method as written above gives the following output.

There are 43 books.
They weigh 70.3 pounds.


Here is an incomplete version of the BoxOfBooks class. Complete the definition so that the BookWork driver will work properly with your enhanced definition for BoxOfBooks.


// <![CDATA[ setLineNumbers(false); setStartLineNumber(1); setJavaCodeFontSize(3); document.write(formatJavaCode("public class BoxOfBooks {\n\n private int count;\n private double weight;\n\n public BoxOfBooks(int c, double w) {\n count = c;\n weight = w;\n }\n\n public int getCount() {\n return count;\n }\n")); ]]> public class BoxOfBooks {

   private int count;
   private double weight;

   public BoxOfBooks(int c, double w) {
      count = c;
      weight = w;
   }

   public int getCount() {
      return count;
   }

  

// end class BoxOfBooks

 


2.Suppose you are given the following main method:

public class OrangeTester {

public static void main(String[] args) {
System.out.println("I'm buying some oranges.");
Orange fruit = new Orange(3);
System.out.println("There are " + fruit.getNumber() + " oranges.");
System.out.println("Now I have more.");
fruit.setNumber(7);
System.out.println("Now there are " + fruit.getNumber() + " oranges.");
}
}


This is one example of how to use the Orange class. Running the main method as written above gives the following output.

I'm buying some oranges.
There are 3 oranges.
Now I have more.
Now there are 7 oranges.


Here is an incomplete version of the Orange class. A method definition is missing. Complete the class definition so that the OrangeTester driver will work properly with your enhanced definition for Orange.


// <![CDATA[ setLineNumbers(false); setStartLineNumber(1); setJavaCodeFontSize(3); document.write(formatJavaCode("public class Orange {\n\n private int number;\n\n public Orange(int n) {\n number = n;\n }\n\n public void setNumber(int n) {\n number = n;\n }\n")); ]]> public class Orange {

   private int number;

   public Orange(int n) {
      number = n;
   }

   public void setNumber(int n) {
      number = n;
   }



// <![CDATA[ setLineNumbers(false); setStartLineNumber(1); setJavaCodeFontSize(3); document.write(formatJavaCode("} // end class Orange")); ]]> // end class Orange

 

 

 

#########

#########

The full list of questions (22 questions) is attached under the file's name OWL.java

########

########

 
Attachments:
My Documents.zip (3K)
OWL.java (19K)


   
   
   
   
 
Available Tutorials to this Question
Posted by:
 

$25.00 A+ answers for all 22 question. 100% Correct.

  • This tutorial was purchased 2 times and rated A+ by students like you.
  • Posted on Oct 30, 2009 at 10:17:08PM
A:
Preview: ... ee th ...

The full tutorial is about 4 words long plus attachments.

Attachments:
OWL.java (21K) (Preview)
Posted by:
 

$12.00 Tested Well Java Source Codes

  • This tutorial hasn't been purchased yet.
  • Posted on Oct 30, 2009 at 11:17:52PM
A:
Preview: ... orking fine. If you need you r ...

The full tutorial is about 30 words long plus attachments.

Attachments:
Java Answers.zip (18K) 

 Java Answers/Apple.class
 Java Answers/AppleTester.class
 Java Answers/AppleTester.java
 Java Answers/BookWork.class
 Java Answers/BookWork.java
 Java Answers/BoxOfBooks.class
 Java Answers/City.class
 Java Answers/CityTester.class
 Java Answers/CityTester.java
 Java Answers/Duplex.class
 Java Answers/DuplexTester.class
 Java Answers/DuplexTester.java
 Java Answers/Lemon.class
 Java Answers/LemonTester.class
 Java Answers/LemonTester.java
 Java Answers/Mango.class
 Java Answers/MangoTester.class
 Java Answers/MangoTester.java
 Java Answers/Music.class
 Java Answers/MusicTester.class
 Java Answers/MusicTester.java
 Java Answers/OfficeBldg.class
 Java Answers/OfficeBldgTester.class
 Java Answers/OfficeBldgTester.java
 Java Answers/Orange.class
 Java Answers/OrangeTester.class
 Java Answers/OrangeTester.java
 Java Answers/SingleFamily.class
 Java Answers/SingleFamilyTester.class
 Java Answers/SingleFamilyTester.java
 Java Answers/Warehouse.class
 Java Answers/WarehouseTester.class
 Java Answers/WarehouseTester.java
 ]

Posted by:
Neel
Neel
Rating (237): C
Questions Asked: 0
Tutorials Posted: 1637, earned $2,004.41
 

$10.00 Solution

  • This tutorial hasn't been purchased yet.
  • Posted on Oct 31, 2009 at 07:22:51PM
A:
Preview: ... ched the ...

The full tutorial is about 6 words long plus attachments.

Attachments:
Answers_Solution.txt (8K) (Preview)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty