to be done in java Your task is to finish the StockItem class so that it...

60.1K

Verified Solution

Question

Programming

to be done in java

Your task is to finish the StockItem class so that it meets thefollowing criteria

• The StockItem class will have 4 attributes:

a stock number;

a name;

the price of the item;

the total number of items currently in stock

• The first three of the above characteristics will need to beset at the time a StockItem object is created, with the totalnumber of items set to 0 at this time. The stock number and namewill not need to be changed after an item is created.

• The following methods are also required:

o A method that allows the price to be re-set during theobject's lifetime

o a method that takes an integer argument and adds this to thetotal number of items in stock

o a method that returns the total value of items of this stocktype;

calculated by multiplying the price of the item by the number ofitems in stock (price * units)

Required Methods: StockItem(String, String, double) (classconstructor) setPrice(double) increaseTotalStock(int)getStockNumber(): String getName(): String getTotalStock(): intgetPrice(): double calculateTotalPrice(): double

Requested files StockItem.java

/** * A class representing an item in stock in some sort * ofinventory system */

public class StockItem {

//TODO: add fields for a: name, stockNumber, price, units.

//TODO: create a constructor that takes name, stockNumber andprice as arguments

// and sets units to 0.

//TODO: create accessor (\"getter\") methods for price, stocknumber and name.

//TODO: create a method increaseTotalStock that increases unitsby a given quantity.

//TODO:create a mutator (\"setter\") method setPrice that setsprice to a given amount.

//TODO: create a method calculateTotalPrice that returns thetotal price of the current inventory

// (Calculated as current price * number of units) }

Answer & Explanation Solved by verified expert
4.4 Ratings (596 Votes)
Code is Given Belowpublic class StockItem private String stockNumber private String name private double pricethe price of the item private int totalNumberthe total number of    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students