Steve
Christopher Goad wrote:I can't seem to figure out where to get started. My class is online and there is really not a good way to communicate. So I just need some advice.
Christopher Goad wrote:Could you possibly help me with my code?
~ Mansukh
Christopher Goad wrote:Could you possibly help me with my code?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Christopher Goad wrote:I'm sorry I forget to post the assignment instructions. Here they are.
15.05 Assignment Instructions
1. Create a folder called 15.05 Assignment in your module 15 assignments folder.
2. Create an interface named Product .
a. Add a method called getName() that returns a string.
b. Add a method called getCost() that returns a double.
3. Create abstract class Vehicle that implements Product.
a. It should have string variable name and double cost, that are initialized in the constructor.
b. Add appropriate getName() and getCost() methods
4. Create classes Car and Truck that extend Vehicle.
a. No other methods are needed.
5. Create class Tool that implements Product and Comparable<T> .
a. It should have string variable name and double cost that are initialized in the constructor.
b. Add appropriate getName() and getCost() methods.
c. Add a compareTo() method that compares tools based upon cost .
6. Create class InventoryDemo.
a. Test your classes by using ArrayList products of following products (Remember to declare it properly using List):
Name
Cost
Jaguar
1000000.00
Neon
17000.00
JigSaw
149.18
Jaguar
110000.00
Neon
17500.00
Neon
17875.32
RAM
35700.00
CircularSaw
200.00
CircularSaw
150.00
b. Create a static method takeInventory that, when passed the name of a product, will go through the list and print out <item name>: Quantity = <quantity>, Total cost = <totalcost>. <item name> is the name of the product, <quantity> and <totalcost> are the values you calculate by going through the list for the product with name that was passed to takeInventory.
c. To test the compareTo() method, create two Tools, saw1 , and saw2 . Give them different prices and then test the compareTo() method you made, by displaying which one is more expensive.
Christopher Goad wrote:I can't seem to figure out where to get started. My class is online and there is really not a good way to communicate. So I just need some advice.
Christopher Goad wrote:I just do not know where to start off at. I'm getting confused...
3. Create abstract class Vehicle that implements Product.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
You know it is dark times when the trees riot. I think this tiny ad is their leader:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
|