Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

* * * JAVA * * * MyComputer class Design a Computer Class. Have users enter different Computers. Store these Computers in an array called

***JAVA***
MyComputer class
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.
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 (MyComputer.LAPTOP, 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 (MyComputer.FREE, MyComputer.CHEAP, MyComputer.EXPENSIVE)
A private variable for weight (MyComputer.HEAVY, MyComputer.MEDIUM, MyComputer.LIGHT)
A static final constant for LAPTOP =1
A static final constant for DESKTOP =2
A static final constant for TABLET =3
A static final constant for OTHER =4
A static final constant for FREE =1
A static final constant for CHEAP =2
A static final constant for EXPENSIVE =3
A static final constant for HEAVY =1
A static final constant for MEDIUM =2
A static final constant for LIGHT =3
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 isLaptop(int), isDesktop(int), isTablet(int), and isOther(int) that return true if the specified type is Laptop, Desktop, Tablet, or Other, respectively.
The static methods isLaptop(MyComputer), isDesktop(MyComputer), isTablet(MyComputer), and isOther(MyComputer) is Laptop, Desktop, Tablet, or Other, respectively.
The method getAge() that returns the age of object computer.
The method sameAge(MyComputer) that returns true if the age in this object is equal to the age of another object.
The method sameAge(int) 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 getCurrentValue(MyComputer) 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.).
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

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

Students also viewed these Databases questions