Forums Register Login

little help???

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
i was just wondering what the question wanted me to do, i couldnt understand the bit where the simpleseattest class came into it.
+Pie Number of slices to send: Send
That is your test harness. It is used to test your SimpleSeat class.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 936 times.
Similar Threads
Help with error in running program
need help with compareTo()
problem with initializing
error....
table sorter
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:37:40.