Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public abstract class Appliance extends Product{ private int wattage; private String color; private String brand; public Appliance(double initPrice, int initQuantity, int initWattage, String initColor, String
public abstract class Appliance extends Product{ private int wattage; private String color; private String brand; public Appliance(double initPrice, int initQuantity, int initWattage, String initColor, String initBrand){ super(initPrice, initQuantity); wattage = initWattage; color = initColor; brand = initBrand; } public String getColor(){ return color; } public String getBrand(){ return brand; } public int getWattage(){ return wattage; } }
public abstract class Computer extends Product{ private double cpuSpeed; private int ram; private boolean ssd; private int storage; public Computer(double initPrice, int initQuantity, double initCPUSpeed, int initRAM, boolean initSSD, int initStorage){ super(initPrice, initQuantity); cpuSpeed = initCPUSpeed; ram = initRAM; ssd = initSSD; storage = initStorage; } public double getCPUSpeed(){ return cpuSpeed; } public int getRAM(){ return ram; } public boolean getSSD(){ return ssd; } public int getStorage(){ return storage; } }
public class Desktop extends Computer{ String towerProfile; public Desktop(double initPrice, int initQuantity, double initCPUSpeed, int initRAM, boolean initSSD, int initStorage, String initProfile){ super(initPrice, initQuantity, initCPUSpeed, initRAM, initSSD, initStorage); towerProfile = initProfile; } public String toString(){ String result = towerProfile + " Desktop PC with " + getCPUSpeed() + "ghz CPU, " + getRAM() + "GB RAM, " + getStorage() + "GB "; if(getSSD()){ result += "SSD drive."; }else{ result += "HDD drive."; } return result; } }
import java.util.ArrayList; import java.util.Scanner; public class ElectronicStore{ public final int MAX_PRODUCTS = 10; //Maximum number of products the store can have private int curProducts; String name; Product[] stock; //Array to hold all products double revenue; public ElectronicStore(String initName){ revenue = 0.0; name = initName; stock = new Product[MAX_PRODUCTS]; curProducts = 0; } public String getName(){ return name; } //Adds a product and returns true if there is space in the array //Returns false otherwise public boolean addProduct(Product newProduct){ if(curProducts = 0 && indexpublic class Fridge extends Appliance{ double cubicFeet; boolean hasFreezer; public Fridge(double initPrice, int initQuantity, int initWattage, String initColor, String initBrand, double initFeet, boolean initFreezer){ super(initPrice, initQuantity, initWattage, initColor, initBrand); cubicFeet = initFeet; hasFreezer = initFreezer; } public String toString(){ String result = cubicFeet + " cu. ft. " + getBrand() + " Fridge "; if(hasFreezer){ result += "with Freezer "; } result += "(" + getColor() + ", " + getWattage() +" watts)"; return result; } }public class Laptop extends Computer{ private double screenSize; public Laptop(double initPrice, int initQuantity, double initCPUSpeed, int initRAM, boolean initSSD, int initStorage, double initScreen){ super(initPrice, initQuantity, initCPUSpeed, initRAM, initSSD, initStorage); screenSize = initScreen; } public String toString(){ String result = screenSize + " inch Laptop PC with " + getCPUSpeed() + "ghz CPU, " + getRAM() + "GB RAM, " + getStorage() + "GB "; if(getSSD()){ result += "SSD drive."; }else{ result += "HDD drive."; } return result; } }public class Product{ private double price; private int quantity; public Product(double initPrice, int initQuantity){ price = initPrice; quantity = initQuantity; } public int getQuantity(){ return quantity; } public double getPrice(){ return price; } //Returns the total revenue (price * amount) if there are at least amount items in stock //Return 0 otherwise (i.e., there is no sale completed) public double sellUnits(int amount){ if(amount > 0 && quantity >= amount){ quantity -= amount; return price * amount; } return 0.0; } }public class ToasterOven extends Appliance{ private int width; private boolean convection; public ToasterOven(double initPrice, int initQuantity, int initWattage, String initColor, String initBrand, int initWidth, boolean initConvection){ super(initPrice, initQuantity, initWattage, initColor, initBrand); width = initWidth; convection = initConvection; } public String toString(){ String result = width + " inch " + getBrand() + " Toaster "; if(convection){ result += "with convection "; } result += "(" + getColor() + ", " + getWattage() +" watts)"; return result; } }For this assignment, you will build a graphical user interface to attach to the electronic store model that you have developed over the previous two assignments. You can use your own model classes from the previous assignment, or you can download and use the model classes included on the assignment page as a starting point. Your assignment must maintain a separation between the GUI and the underlying electronic store model. You must also continue to apply the principles of OOP, such as encapsulation. A recording showing a demonstration of how the GUI should generally work is included on the assignment page. For this assignment, you will build a graphical user interface to attach to the electronic store model that you have developed over the previous two assignments. You can use your own model classes from the previous assignment, or you can download and use the model classes included on the assignment page as a starting point. Your assignment must maintain a separation between the GUI and the underlying electronic store model. You must also continue to apply the principles of OOP, such as encapsulation. A recording showing a demonstration of how the GUI should generally work is included on the assignment page
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started