Step 1: Stock class (10pt) This class is for the new vehicle inventory that your dealership directly purchases from BP
Posted: Wed Apr 27, 2022 5:05 pm
Step 1: Stock class (10pt)
This class is for the new vehicle inventory that your dealership
directly purchases from BP motor. Create
a class called Stock and save it in Stock.java.
The class has the following (private) instance variables:
• An integer variable for stock ID;
• A double variable for purchase price;
The class has the following (public) instance methods:
• Constructor method (Version 1), with no argument:
o Simply set stock ID to 0, and set purchase price to 0;
• Constructor method (Version 2), with two arguments: one for stock
ID, one for purchase price
o Set the stock ID and the purchase price equal to the parameter
values;
• A method to set the stock ID;
• A method to set the purchase price;
• A method to retrieve the stock ID;
• A method to retrieve the purchase price;
• A method to print stock information:
o Print stock ID and purchase price in one line, in a properly
aligned format (see the
screenshot in Step 2; use printf).
This class is for the new vehicle inventory that your dealership
directly purchases from BP motor. Create
a class called Stock and save it in Stock.java.
The class has the following (private) instance variables:
• An integer variable for stock ID;
• A double variable for purchase price;
The class has the following (public) instance methods:
• Constructor method (Version 1), with no argument:
o Simply set stock ID to 0, and set purchase price to 0;
• Constructor method (Version 2), with two arguments: one for stock
ID, one for purchase price
o Set the stock ID and the purchase price equal to the parameter
values;
• A method to set the stock ID;
• A method to set the purchase price;
• A method to retrieve the stock ID;
• A method to retrieve the purchase price;
• A method to print stock information:
o Print stock ID and purchase price in one line, in a properly
aligned format (see the
screenshot in Step 2; use printf).