Question
Using NetBeans: Create a pricing system for a computer company that sells personal computers over the Internet. There are two kinds of computers, laptops and
Using NetBeans:
Create a pricing system for a computer company that sells personal computers over the Internet. There are two kinds of computers, laptops and desktops. Each computer has a processor (1.8. 2.0, 2.5, or 3.0 gigahertz), memory (2, 3 or 4 Gb), hard drive (160, 250, or 500 Gb), and optical drive ("CD-RW", "DVD" or "Blu-ray Combo Drive"). Laptops have 14-, 15- or 17-inch screens. Desktops have 17-, 19-, or 24-inch monitors.
You should have an abstract class Computer and final subclasses LapTop and DeskTop. The 'Computer' class should have set and get methods to modify and retrieve the values of its instance variables (processorSpeed, memorySize, hardDriveSize, and opticalDriveType, and both the 'LapTop' and 'DeskTop' classes should have sets and gets for its only instance variable, the displaySize field. Include validation coding in all the set methods based upon the field values given in the previous paragraph. Since all computers must have all components, establish a default value for each component, i.e. zero (0) or an empty String, meaning that no valid value currently exists for that component.
The constructor methods of all three classes should take parameters for initializing all instance variables; additionally the subclass constructors should pass related parameters to the superclass constructor. Also include "no-parameter" constructors that set default values for the two subclasses.
For every component include a get...Price() method that calculates the price for that individual component. As an example, for the processor there should be a getProcessorPrice() method in the 'Computer' class that uses if proceesing to return the processor price. This is in addition to the setProcessorSpeed() and getProcessorSpeed() methods.
Each subclass should have a public method named getComputerPrice(), that calculates and returns a double which is the price of a computer given the base price (different for a laptop or a desktop) plus the cost of the different options (e.g. Price = Base price + Processor price + Memory price + Hard drive price + Optical drive price + Display price). Create an abstract method in the 'Computer' class so that it can call this method from the two subclasses.
Also in the 'Computer' class declare three abstract method prototypes for the display size attribute: setDisplaySize(), getDisplaySize() and getDisplayPrice(). This will force all subclasses of the 'Computer' class to implement these methods as well as allowing the toString() method of class 'Computer' (see below) to call the subclass getDisplaySize() method.
Create an interface BasePrices with constants for the base prices of the laptop and desktop computers. These interfaces both should be implemented by the 'LapTop' and 'DeskTop' subclasses.
Write a single toString() method situated in the 'Computer' class that returns the specifications for each computer object (processor speed, memory size, hard drive size, optical drive type, and display size) with appropriate labeling for readability, plus the computer price which is returned from the getComputerPrice() method of either the 'LapTop' or 'Desktop' subclass.
Write a test (driver) class with a main() method that instantiates objects from the 'LapTop' and 'DeskTop' classes, and which directly or indirectly demonstrates all the set, get and toString() methods of all classes. This test application should instantiate an array of 'Computer' objects and then iterate through and display them as a collection.
Provide full documentation based upon the downloaded sample files for the unit: (a) the superclass and subclass documentation should follow Javadoc standards including stating the validation rules, e.g. valid values and/or ranges, for the set methods; and (b) the driver class may use more general comments that describe the overall function of the application and each of its methods.
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