Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Lab 6 
Classes/Constructors 
 
The following exercises are to be completed during lab class.  If you do not 
have time to finish during lab, they must be completed before the 
beginning of the following lab session. 
 
Set-Up 
 Create a new project in your Eclipse workspace named:  Lab06 
 In the src folder, create a package named:  edu.ilstu 
 Import the following file from T:/it168/Labs/Lab06 
o TruckTester.java 
 
Part 1 
 
Requirements 
Implement the WidgetProducer class you designed for pre-lab. 
 
Demonstrate the WidgetProducer class by writing a WidgetTester class that has a 
main method.  Create three WidgetProducer objects, one for each test case.  Call the 
method and display the number of days formatted to one decimal place. 
 
Sample Output for one test case: 
100 widgets produced at 10 per hour will take 0.6 days. 
 
Part 2 
Write the complete code for the class Truck as given in the class diagram below.  Be 
sure to not use duplicate code in the constructors.  For example, the constructors 
with 2 arguments should call the one with 1 argument to set the value for cylinder. 
 
Use the provided file TruckTester.java to test your class. 
  
Truck 
- cylinders:int 
- manufacturer:String 
- load:double 
- tow:double 
 
+ Truck() 
+ Truck(int cylinders) 
+ Truck(int cylinders, String manufacturer) 
+ Truck(int cylinders, String manufacturer, double load) 
+ Truck(int cylinders, String manufacturer, double load,  
              double tow) 
+ getCylinders():int 
+ setCylinders(int cylinders):void 
+ getManufacturer():String 
+ setManufacturer(String manufacturer):void 
+ getLoad():double 
+ setLoad(double load):void 
+ getTow():double 
+ setTow(double tow):void 
+ toString():String 
 
 
Use the following to code the toString() method.  (You will be learning how to 
write this in a couple of weeks.) 
 
 public String toString() 
 { 
  return “\n\ncylinders = ” + cylinders 
               + “\nmanufacturer = ” + manufacturer 
       + “\nload = ” + load 
       + “\ntow = ” + tow; 
 } 
 
 
 
To Be Submitted 
The following files should be zipped together into a file called Lab06.zip and 
submitted to ReggieNet by the beginning of your next lab. 
 WidgetProducer.java 
 WidgetTester.java 
 Truck.java