Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Computer class. Summary: Design a Computer Class. Have users enter different Computers. Store these Computers in an array called Inventory. Output information using the
The Computer class.
Summary:
Design a Computer Class.
Have users enter different Computers.
Store these Computers in an array called Inventory.
Output information using the Inventory Array and object attributes and methods.
Class Specification:
Attributes:
A private int data field named id that stores the id number for the computer. This number must be associated with the object when created.
A private data field for Computer Name
A private data field for Computer Type MyComputerLAPTOP, MyComputer.DESKTOP, MyComputer.TABLET, MyComputer.OTHER
A private data field for manufacturer
A private data field for age in years
A private data field for generated Current Value.
A private data field of your choosing something other than what is already defined, this will be used to differentiate your program from others : Be Creative!
A private variable for Purchase Cost MyComputerFREE, MyComputer.CHEAP, MyComputer.EXPENSIVE
A private variable for weight MyComputerHEAVY, MyComputer.MEDIUM, MyComputer.LIGHT
A static final constant for LAPTOP
A static final constant for DESKTOP
A static final constant for TABLET
A static final constant for OTHER
A static final constant for FREE
A static final constant for CHEAP
A static final constant for EXPENSIVE
A static final constant for HEAVY
A static final constant for MEDIUM
A static final constant for LIGHT
Methods:
A constructor that creates a MyComputer object with all default attributes other than id pass in id
A constructor that creates a MyComputer object with all attributes defined when the object is created.
The methods isLaptop isDesktop isTablet and isOther that return true if the computer type in this object is Laptop, Desktop, Tablet, or Other, respectively.
The static methods isLaptopint isDesktopint isTabletint and isOtherint that return true if the specified type is Laptop, Desktop, Tablet, or Other, respectively.
The static methods isLaptopMyComputer isDesktopMyComputer isTabletMyComputer and isOtherMyComputer is Laptop, Desktop, Tablet, or Other, respectively.
The method getAge that returns the age of object computer.
The method sameAgeMyComputer that returns true if the age in this object is equal to the age of another object.
The method sameAgeint that returns true if the age in this object is equal to the specified value.
The method generateCurrentValue Calculate price how you wish but it should consider each of the cost, type and age of the computer.
The method getCurrentValueMyComputer that returns the generated current value of the computer.
A method of your choosing something other than what is already defined, this will be used to differentiate your program from others : Be Creative!
Override toString to output all attributes output must be user readable ie Laptop, Desktop, Free, Expensive, etc.
Example dont forget to include your unique attribute, not shown here
ID:
Name........: OPERROOM
Type........: Desktop
Manufacturer: HP
Weight......: Heavy
Age.........:
Cost........: Expensive
Value.......: $
Processing:
All computers must be stored in an Inventory array.
Write a test program in a different file from your object that allows a user to create and input an inventory of computers. Prompt the user to enter computers until they indicate they are done.
Store the computers in your inventory array.
Print a toString for each Computer.
Summarize the complete inventory by listing the total number of computers, total number by manufacturer, average age to two decimal places, average price to two decimal places, and total cost.
Format all outputs neatly, using proper spacing, decimal places, and new lines as appropriate.
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