77 lines
2.0 KiB
Java
77 lines
2.0 KiB
Java
/*
|
|
*
|
|
* Given main(), define the Product class that will manage
|
|
* product inventory
|
|
*
|
|
* three private member fields
|
|
* *productCode (String)
|
|
* *productPrice (double)
|
|
* *productInInventory (int)
|
|
*
|
|
* public Product(String code, double price, int count)
|
|
* ** Set the member fields using the three params
|
|
*
|
|
* public void setCode(String code)
|
|
* ** Set the product code to parameter code
|
|
*
|
|
* public String getCode() -- return product code
|
|
*
|
|
* public void setPrice(double p) - set price to parameter p
|
|
*
|
|
* public double getPrice() -- return price
|
|
*
|
|
* public void setCount(int num)
|
|
* **set the number of items in inventory to parameter num
|
|
*
|
|
* public int getCount() -- return count
|
|
*
|
|
* public void addInventory(int amt) - increase inventory by amt
|
|
* public void sellInventory(int amt) - decrease inv by amt
|
|
*/
|
|
|
|
// Lots of stuff in this assignment on black board all run together
|
|
// somewhat hard to review and be sure I noticed everything.
|
|
// it's also not clear what
|
|
// "Given main(), define the Product class..."
|
|
// I'm reading that as, I don't have to write a main file (except to test)
|
|
// Though, it makes me think I should have some main file available to me.
|
|
//
|
|
// So, I wrote a main file for myself to do the printing for testing that
|
|
// outputs as in the example. And as instructed, I'll only upload my class code
|
|
|
|
public class Product {
|
|
private String code;
|
|
private double price;
|
|
private int count;
|
|
|
|
public Product (String code, double price, int count){
|
|
this.code = code;
|
|
this.price = price;
|
|
this.count = count;
|
|
}
|
|
public void setCode(String code){
|
|
this.code = code;
|
|
}
|
|
public String getCode(){
|
|
return this.code;
|
|
}
|
|
public void setPrice(double price){
|
|
this.price = price;
|
|
}
|
|
public double getPrice(){
|
|
return this.price;
|
|
}
|
|
public void setCount(int count){
|
|
this.count = count;
|
|
}
|
|
public int getCount(){
|
|
return this.count;
|
|
}
|
|
public void addInventory(int amt){
|
|
this.count += amt;
|
|
}
|
|
public void sellInventory(int amt){
|
|
this.count -= amt;
|
|
}
|
|
}
|