Subject JAVA Thank you. Create an abstract base class called Item with member variables for name and value. Also include a static integer for keeping
Subject JAVA
Thank you.
Create an abstract base class called Item with member variables for name and value. Also include a static integer for keeping track of the total number of Items created. Provide a toString() method for displaying the labeled values of the member variables. Provide a constructor to set default values and to increase the static integer. Add abstract methods called use() and use(item). Note that using the same name with different parameters is called overloading.
From Item derive 2 abstract classes Tool and Consumable. Add the following members: -Tool Public enum Grade {provide 4 grades of quality} grade -Grade Tool() toString() use() use(Item) -Consumable numberOfCharges- int consumable() toString() use() use(Item) Create 2 subclasses from Tool and 2 subclasses from Consumable. Provide constructors, ToString() methods and at least 1 member variable of your own unique to each of these classes. Provide definitions for use() and use(Item) that operate in the following way. At least 3 of your items need to interact with each other. Others may be usable independently. In either case display a message to the screen indicating to the user what has taken place.
In main() create 1 object for each of your items. Display the items in a menu and prompt the user for which item will be used. Then prompt for a second item to use the first item on. Call the use() or use(Item) method based on the users input.
The Program may look like this: Apples Grapes Knife Bottle Exit Which item will you use: 2 Which item will be used with the grapes? (0 for none): 4
You squeeze the grapes into the bottle. The grapes begin to ferment. (Loop from here)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started