Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, I need some help creating this project for an exercise I found in my textbook. I am having trouble doing the project. Down below
Hello, I need some help creating this project for an exercise I found in my textbook. I am having trouble doing the project. Down below I will have the instructions that I was told to use to help me Create a project called electronicsproject.
Create classes, one called Electronics, another called TechItem.
In the TechItem class:
Insert comments
Make fields for the class the type of tech item String the price double
and the inventory amountint
Create the constructor for the class. Set it up so that the type, price and inventory will be sent as parameters.
Write accessor methods to access the type, price, and inventory.
Write a mutator method to print the type, price and inventory.
Write mutator methods to set the type, price, and inventory.
Write a mutator method to add to the inventory amount.
Write a mutator method to subtract from the inventory amount. Before you do
the subtraction, check to see if the inventory will go below If it will, do not
do the subtraction and print a message that you need to restock the item.
In the Electronics class:
Insert proper comments
Make a field for store name String Also set up an ArrayList of TechItem
objects. I called mine electronicsList
Create the constructor for the class, assuming the user will enter the store
name. Instantiate the ArrayList.
Create an accessor method to get the store name.
Code a method to populate the electronics ArrayList with TechItem objects
hint: you will need to use the add method of ArrayList
Create a mutator method to print out the store name, and the info for each
tech Item object in your list. hint: use the foreach loop to do this and call on
a method from the TechItem class
Code a method to get the last item on your listss type. use method from the ArrayList and TechItem classes. Return the type of the last item on your list.
You may add additional methods to your class to make it more functional.
Code a method in the Electronics class to buy tech items. You will have the user enter the item number that you want from the list of tech items, and the number of those items that you want to purchase. You can get the users request through parameters. Multiple the cost of the item by the number of items purchased to get the total cost. Subtract the number of items from the inventory amount for that item. Print out the type of item that you purchased, how many, the total cost and the current inventory for that item.
Get the info from the user in any of your methods using the Scanner class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
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