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.
See the following link for UML diagram
You should have an
abstractclass Computer and
finalsubclasses 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
ifproceesing to return the processor price. This is in addition to the setProcessorSpeed
Each subclass should have a public method named getComputerPrice
(), that calculates and
doublewhich 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
abstractmethod in the 'Computer' class so that it can call this method from the two subclasses.
Also in the 'Computer' class declare three
abstractmethod prototypes for the display size attribute: setDisplaySize
(). 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
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.
- Students may work on all projects in teams of two or three, and, if so, all students in the group must submit the same project to their own dropboxes in Blackboard. In the text box's dropbox, as well as in the source code documentation (comments), state the name(s) of the classmate(s) with whom you worked.
- When all steps are finished, create a .ZIP archive (not a .RAR) of the entire project. This completed assignment with a copy of all files from the NetBeans project submitted electronically via an attachment to a Blackboard dropbox is due to Prof. Struck by 11:59 p.m. on the date specified in the course outline.