Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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 && index  

public 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; } }
Assignment 3 Graphical user interfaces Submit a single ZIP file called assignment3.zip containing each of your Java files just the .java extension files). Your zip file must contain only .java files organized into a single folder (i.e., no packages, sub-folders, etc.) and the TAs should be able to compile all your code within this same folder (i.e., your code should also not reference packages). This assignment has 50 marks. See the marking rubric that is posted on the course webpage. 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 1) The GUI Create a class called ElectronicStoreApp (extend JavaFX's Application class), which wil construct the GUI shown below. You should make the GUI window non-resizable. The ratio of the window width/height should be approximately 2:1 (e.g., 800 wide, 400 high) : Electronic Store Application Store Summary Store Stock: Current Cart # Sales: Revenue: s/Sale Most Popular Items: Reset Store Assignment 3 Graphical user interfaces Submit a single ZIP file called assignment3.zip containing each of your Java files just the .java extension files). Your zip file must contain only .java files organized into a single folder (i.e., no packages, sub-folders, etc.) and the TAs should be able to compile all your code within this same folder (i.e., your code should also not reference packages). This assignment has 50 marks. See the marking rubric that is posted on the course webpage. 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 1) The GUI Create a class called ElectronicStoreApp (extend JavaFX's Application class), which wil construct the GUI shown below. You should make the GUI window non-resizable. The ratio of the window width/height should be approximately 2:1 (e.g., 800 wide, 400 high) : Electronic Store Application Store Summary Store Stock: Current Cart # Sales: Revenue: s/Sale Most Popular Items: Reset Store

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions