aspose file tools*
The moose likes Beginning Java and the fly likes error.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error...." Watch "error...." New topic
Author

error....

phil porter
Greenhorn

Joined: Nov 30, 2001
Posts: 2
hello
in follow up to my previous thread.. i have written the code although there is a small error:
my task is to....
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

at the moment i have:
public class SimpleSeat {

public void setStatus(int newStatus) {

//something here

}

public int getRow(){
int getRow= 0;
return getRow;
}

public int getPosition() {
int getPosition = 0;
return getPosition;
}

public int getStatus() {
int getStatus = 0;
return getStatus;
}

public SimpleSeat(int a, int b) {
}
}

i need to insert something into the place i marked but not sure whether getRow needs modifying too. i have tried a few things that compiled but kept resetting the status to 0
can anyone help further as im quite new to this.
thanks
phil
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Phil,
First you are not following the instructions. The SimpleSeat class must have the following class variables:

Then inside your accessors should not reset them. They should look something like:

This is probably a good start the rest shouldn't be to bad to figure out.
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error....