Volkof
Well-Known Member
- Reaction score
- 31
Hi all,
Lets say I have these classes:
======================================================
Every Plane Seat has a seatId, and only 1 customer can be assigned to it.
Assigning Seat ..
Please enter SeatID: 10
Please enter Customer ID: 10001
Seat Assigned!
======================================================
Now I have a Plane:
Every Plane can have up to 12 seats
======================================================
Now lets say
However I need to print out in sorted order of CustomerID, so it should become like this:
How do I sort the PlaneSeat objects in ascending order of their CustomerID?
To my knowledge, I should use:
Something like
Arrays.sort(PlaneSeats, Sort by CustomerID)?
Thanks in advance
Lets say I have these classes:
======================================================
Code:
public class PlaneSeat {
//Attributes
private int seatId;
private int customerId;
private boolean assigned;
}
Every Plane Seat has a seatId, and only 1 customer can be assigned to it.
Assigning Seat ..
Please enter SeatID: 10
Please enter Customer ID: 10001
Seat Assigned!
======================================================
Now I have a Plane:
Code:
public class Plane {
//Attributes
private int totalSeats = 12;
private PlaneSeat PlaneSeat[];
private int numEmptySeat = totalSeats;
}
======================================================
Now lets say
Code:
SeatID 1 assigned to CustomerID 1009
SeatID 2 assigned to CustomerID 1004
SeatID 3 assigned to CustomerID 1005
However I need to print out in sorted order of CustomerID, so it should become like this:
Code:
SeatID 2 assigned to CustomerID 1004
SeatID 3 assigned to CustomerID 1005
SeatID 1 assigned to CustomerID 1009
How do I sort the PlaneSeat objects in ascending order of their CustomerID?
To my knowledge, I should use:
Code:
import java.util.Arrays;
Arrays.sort()
Something like
Arrays.sort(PlaneSeats, Sort by CustomerID)?
Thanks in advance