hi im trying to do this question but getting nowhere...
could someone point me in the right direction?
would be much appreciated, phil
-------
Develop a class SimpleSeat that describes a seat on a plane. The SimpleSeat class has instance variables describing:
�the row number, an int, which is zero for the first row of seats, one for the second row, and so on.
�the position in the row, an int, counting from zero for the leftmost seat of the row.
�the status of the seat, which is an int whose possible values are:
o0 the seat is free.
o1 the seat is reserved: it will either be allocated to a passenger or freed.
o2 the seat has been allocated to a passenger.
The SimpleSeat class has the following methods, callable from any other object:
A constructor with two int arguments specifying the row (counting from zero), and position in the row (counting from zero), of the seat. This constructor should initialise the status of the seat to 0.
�int getRow() that returns the row number of the seat.
�int getPosition() that returns the position in the row of the seat.
�int getStatus() that returns the status of the seat.
�void setStatus(int newStatus) to change the status of the seat.
Use the following class to test the SimpleSeat class:
public class SimpleSeatTest {
public static void main( String[] args ) {
SimpleSeat seat;// Seat object to test.
int row;// Row number of seat.
int pos;// Position in row of seat.
int status;// Seat status.
seat = new SimpleSeat(0,0);// Create a SimpleSeat object.
row = seat.getRow();
pos = seat.getPosition();
status = seat.getStatus();
System.out.println( "SimpleSeat: row=" + row +
" position=" + pos + " status=" + status );
seat.setStatus( 1 );
System.out.println( "SimpleSeat status changed:" );
status = seat.getStatus();
System.out.println( "Seat status=" + status );
}
}
The output from SimpleSeatTest should be:
SimpleSeat: row=0 position=0 status=0
SimpleSeat status changed:
Seat status=1
could someone point me in the right direction?
would be much appreciated, phil
-------
Develop a class SimpleSeat that describes a seat on a plane. The SimpleSeat class has instance variables describing:
�the row number, an int, which is zero for the first row of seats, one for the second row, and so on.
�the position in the row, an int, counting from zero for the leftmost seat of the row.
�the status of the seat, which is an int whose possible values are:
o0 the seat is free.
o1 the seat is reserved: it will either be allocated to a passenger or freed.
o2 the seat has been allocated to a passenger.
The SimpleSeat class has the following methods, callable from any other object:
A constructor with two int arguments specifying the row (counting from zero), and position in the row (counting from zero), of the seat. This constructor should initialise the status of the seat to 0.
�int getRow() that returns the row number of the seat.
�int getPosition() that returns the position in the row of the seat.
�int getStatus() that returns the status of the seat.
�void setStatus(int newStatus) to change the status of the seat.
Use the following class to test the SimpleSeat class:
public class SimpleSeatTest {
public static void main( String[] args ) {
SimpleSeat seat;// Seat object to test.
int row;// Row number of seat.
int pos;// Position in row of seat.
int status;// Seat status.
seat = new SimpleSeat(0,0);// Create a SimpleSeat object.
row = seat.getRow();
pos = seat.getPosition();
status = seat.getStatus();
System.out.println( "SimpleSeat: row=" + row +
" position=" + pos + " status=" + status );
seat.setStatus( 1 );
System.out.println( "SimpleSeat status changed:" );
status = seat.getStatus();
System.out.println( "Seat status=" + status );
}
}
The output from SimpleSeatTest should be:
SimpleSeat: row=0 position=0 status=0
SimpleSeat status changed:
Seat status=1