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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "little help???" Watch "little help???" New topic
Author

little help???

sventon
Greenhorn

Joined: Nov 30, 2001
Posts: 2
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
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
So what do you have so far???

At least show a little effort before asking for help with homework. We don't mind helping but don't ask to have it done. You could at least have gotten the instance variables and get and set methods. Where exactly to you need to help?
sventon
Greenhorn

Joined: Nov 30, 2001
Posts: 2
i was just wondering what the question wanted me to do, i couldnt understand the bit where the simpleseattest class came into it.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
That is your test harness. It is used to test your SimpleSeat class.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You should be able to sketch out the SimpleSeat class structure even if you are not sure of all of the code. That would show that you thought about it some. You might consider using an array
int[][] seatStatus;
to hold the status of each seat. The first index would represent the row and the second the Position. The value held in each element would represent the actual status of the seat. This would need to be a static variable to insure that it was visible across all of the instances.
You are going to have to invent a limit on the number of rows and seats in a row, since the instructions do not specify that.
Also sventon,
Please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.
Thanks,
Cindy

"JavaRanch, where the deer and the Certified play" - David O'Meara
phil porter
Greenhorn

Joined: Nov 30, 2001
Posts: 2
hi, sorry about that.. well at the moment i have this:
public class SimpleSeat {

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

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

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

public int setStatus(int setStatus) {
}

public SimpleSeat(int a, int b) {

SimpleSeat = new SimpleSeat (a,b);

}

public static void main(String[] args) {
int getStatus = 0;

}
}

this satisfies the question as i understand it although it gives me an error with the simpleseattest class saying,
java.lang.NoSuchMethodError
at SimpleSeatTest.main(SimpleSeatTest.java:8)
Exception in thread "main"
im sorry if my thing is hard to understand but im still a beginner at all this malarky
anyone point me in the right direction?
phil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: little help???