Write a program which works out which is the lowest priced computer in an ArrayList of computer obje
Posted
by Eoin
on Stack Overflow
See other posts from Stack Overflow
or by Eoin
Published on 2010-04-29T17:53:39Z
Indexed on
2010/04/29
17:57 UTC
Read the original article
Hit count: 302
Hello everybody! I am trying to study some java and cannot get my head around this question! Any help would be really appreciated and would help me in further studies! Thank you so much in advance! Eoin from Dublin, Ireland.
ArrayList of Objects Write a program which works out which is the lowest priced computer in an ArrayList of computer objects.
You should have two classes, one called ComputerTest, and the other called Computer.
In the ComputerTest class you should:
Have a main method which declares an ArrayList of type Computer called computerList, each element of which represents a computer. Initialise the first three entries of the ArrayList Call a static method which prints out the lowest price computer, called lowestPrice The parameter of this method is (i) an ArrayList of type Computer i.e. ArrayList data
Sample output:
The lowest priced computer is the Cheapo400 at 399 euro.
The Computer class should have:
Private instance variables: manufacturer, model, price and quality. Quality is a rating from 1 to 10. public get and set methods to retrieve and set/change the value of the four instance variables a default constructor a constructor that takes four parameters
© Stack Overflow or respective owner