Question: In java please In addition to simply storing different types of data and basic getter/setter methods, objects can also store more complicated methods to manipulate
In java please
In addition to simply storing different types of data and basic getter/setter methods, objects can also store more complicated methods to manipulate and update the objects internal data. One of the first methods to execute in an object, is the objects constructor. This method is called whenever you instantiate a new instance of the class. While, for the most part, it is not required that you define a constructor for you class, due to a class always having a default constructor provided by Java, it is sometimes helpful to defined one to initialize certain variables when the object is being created. For this exercise you will be creating a warehouse inventory tracker. You will first need to create a warehouse class and then use that class, along with a menu implemented via a switch, to allow the user for modify the contents of the warehouse. In a file named Warehouse.java , define a class named Warehouse to store information related to the goods in the warehouse. The class should contain: o A private integer variable to store the total number of goods in the warehouse, along with an appropriate getter, but not setter, method o A constructor method that takes in a single integer variable as a parameter and uses that variable to set the initial number of goods in the warehouse o A method that prompts the user for how many goods they would like to add to the warehouse and then increments the total number of goods by that amount o A method that prompts the user for how many goods they would like to remove from the warehouse and then decrements the total number of goods by that amount. Your method should not remove more goods than you currently have, and should warn this user if they try to make this mistake In a file named Manager.java , define a class named Manager to organize the users access to the warehouse. The class should contain: o Your main method, which should contain: A single instance of a Warehouse object, with the total number of goods in the warehouse set to 0. Be sure to use your constructor to set the value A loop that outputs a menu of options regarding the warehouse (add goods, remove goods, output total, quit), prompts the user for which option they would like, and uses a switch to either call that particular method in the Warehouse object OR quits the loop if they select quit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
