First and foremost, I've read a bunch of links on the web and I still can't implement the methods I've found in this specific context, please help me by providing me some sort of guidance.
The object in question is the Property Object.
It has 3 attributes
int value, int rent, Person owner (assuming class Person exists).
I need to create an array of 10 Property objects, assign the value attribute with random numbers and sort them by value in ascending order:
Property[] street = new Property [10];
for (int i=0;i<street.length;i++)
{
int propertyValue = (int)(200000*Math.random());
int propertyRent = (int)(49*Math.random())+1;
street[i] = new Property(propertyValue, propertyRent, null);
System.out.println (street[i]);
}
Basically what I need to do is this:
If I have 3 Property objects with the following attributes:
property value: $181,230.00 rent: $22.00 owner: null
property value: $112,169.00 rent: $15.00 owner: null
property value: $128,237.00 rent: $43.00 owner: null
I need to sort them in ascending order by value and display them like this:
property value: $112,169.00 rent: $15.00 owner: null
property value: $128,237.00 rent: $43.00 owner: null
property value: $181,230.00 rent: $22.00 owner: null