Show differencesHistory of post edits
#1PsychotikRabbit
Posted 11 December 2012 - 07:04 PM
Alright, I think you must not overdo what the homework is about.
First of all let's check those problem's rules.
Problem:
-Create a java program in which an airline can keep track of it's seating assignments.
Using an array for this problem can be a solution. You used a Integer array, so why not defining
two integers as the "current state of a seat" : 0 as free seat and 1 as occuped seat. Now this way you can
keep track of the number of available seats.
Your array "seats[]" would contain the state of each seat in the plane.
-Using the InputDialog Method ask the user how many people will be coming aboard the plane.
You seems to understand how to use the input dialog already, but remember that you need to ask how many people
will be coming abord the plane. That means you are asking how many seats will become occuped by that same input.
Using a loop to change up the seats' states would be a good idea then.
- The plane consists of only 5 seats.
That is the maximum value of your array, you must consider the user's input so he can't ask for more than the remaining free seats.
(Maybe an ErrorMessage with JOptionPane).
- Keep assigning people to the seats in the plane until all seats are filled.
Five seats with the occuped state must be the condition of the end of the application. That means that the application must loop
to ask the input while there is still free seats.
-Once every seat is filled tell the user no more seats are avaiable.
Count the number of seat with the occuped state and compare it with the maximum seats, if it equals then tell the user that there are no mroe seats available.
This is not a perfect application, but it should fit for the homework needs, I hope that will help you.
First of all let's check those problem's rules.
Problem:
-Create a java program in which an airline can keep track of it's seating assignments.
Using an array for this problem can be a solution. You used a Integer array, so why not defining
two integers as the "current state of a seat" : 0 as free seat and 1 as occuped seat. Now this way you can
keep track of the number of available seats.
Your array "seats[]" would contain the state of each seat in the plane.
-Using the InputDialog Method ask the user how many people will be coming aboard the plane.
You seems to understand how to use the input dialog already, but remember that you need to ask how many people
will be coming abord the plane. That means you are asking how many seats will become occuped by that same input.
Using a loop to change up the seats' states would be a good idea then.
- The plane consists of only 5 seats.
That is the maximum value of your array, you must consider the user's input so he can't ask for more than the remaining free seats.
(Maybe an ErrorMessage with JOptionPane).
- Keep assigning people to the seats in the plane until all seats are filled.
Five seats with the occuped state must be the condition of the end of the application. That means that the application must loop
to ask the input while there is still free seats.
-Once every seat is filled tell the user no more seats are avaiable.
Count the number of seat with the occuped state and compare it with the maximum seats, if it equals then tell the user that there are no mroe seats available.
This is not a perfect application, but it should fit for the homework needs, I hope that will help you.