Question: Create a class called Product. Declare private member fields for a product code (String) a price (double) and the number in inventory (int). Provide a

Create a class called "Product". Declare private member fields for a product code (String) a price (double) and the number in inventory (int). Provide a constructor, get methods and set methods as shown below.

public Product(String code, double price, int count) - set the instance fields using the three parameters public void setCode(String code) - set the product code (i.e. SKU234) to parameter 'code' public String getCode() - return the product code public void setPrice(double p) - set the price to parameter 'p' public double getPrice() - return the price public void setCount(int num) - set the number of items in inventory to parameter 'num' public int getCount() - return the count public void addInventory(int amt) - increase inventory by parameter 'amt' public void sellInventory(int amt) - decrease inventory by parameter 'amt'

/************************************************************** Simple class to hold product information *************************************************************/ public class Product { // FIX ME: define three private member fields public Product(String code, double p, int count){ } /************************************************************** Assign the parameter to the instance field for name *************************************************************/ public void setCode(String c){ //FIX ME: assign parameter to instance field } // FIX ME: Add more metods // this method does nothing but is needed for testing public static void main(String args[]){ } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!