How can I change the values in an object instantiated from a class formed from an abstract class?
In this program I want to decrease the amount of stock from each flower count by using a function called subRoseStock() that takes in a variable called amtRosesInStock and subtracts the order value the customer gives from it. Here is the code:
//Flower Class public abstract class Flower{ String name; String color; int orderAmt; double price; Flower(){ name="Unknown name"; color="Unknown color"; orderAmt=0; price=0.00; } Flower(String name, String color, int orderAmt){ this.name=name; this.color=color; this.orderAmt=orderAmt; } public String getFlowerName(){ return name; } public double getFlowerPrice(){ return price; } public String getFlowerColor(){ return color; } public int getorderAmt() { return orderAmt; } } //Rose class public class Rose extends Flower { public Rose(){ name="Rose"; price=1.50; color="Red"; orderAmt=0; } public Rose(String name, String color, int amtinstock) { super(name, color, amtinstock); } public String getFlowerName() { return name; } public double getFlowerPrice() { return price; } public String getFlowerColor() { return color; } public int getorderAmt() { return orderAmt; } } //FlowerInventory public class FlowerInventory { int amtRosesInStock; int amtGeraInStock; int amtOrchidInStock; public int getRoseStock(){ return amtRosesInStock; } public int getGeraInStock(){ return amtGeraInStock; } public int getOchidInStock(){ return amtOrchidInStock; } public int restockRoses(){ amtGeraInStock=100; return amtGeraInStock; } public int restockGeranium(){ amtRosesInStock=100; return amtGeraInStock; } public int restockOrchid(){ amtOrchidInStock=100; return amtOrchidInStock; } /*public void subRoseStock(int amtRosesInStock){ amtRosesInStock=amtRosesInStock-Rose.getOrderAmt(); }*/ }