Question: You will write the Flight method assignGroup, which is described as follows. The parameter to the Flight method assignGroup is a list of passengers, group.

You will write the Flight method assignGroup, which is described as follows. The parameter to the Flight method assignGroup is a list of passengers, group. These passengers require a block of adjacent seats in a single row.assignGroup searches for group, size () adjacent empty seats in some row. If such a block of seats is found, the passengers in group will be assigned to those seats, and assignGroup returns true. Otherwise, no passengers are assigned to seats, and assignGroup returns a false. For example, the seats in Flight ap324 are as shown in the first diagram below. If the array adults contains three passengers, the call ap314.assignGroup(adults) makes no changes to ap314 and returns false, because there is not block of three adjacent empty seats in a single row. On the other hand, suppose the array kids contains passengers "Sam" and "Alex". The call ap314.assignGroup (kids) will assign "Sam" and "Alex" to the seats shown in the second diagram below and return true. Contents of my Seats for ap314 before any call to assignGroup [0] [1] [2] [3] [4] window aislo aisle middle window [O] "Kelly" "Sandy Thanh aisle aisle middle window [1] window "Chris" Pat Contents of my Seats for ap314 after call to ap314.assignGroup (kids). [0] (1) [21 (3) (4) window aisle aisle middle window [O] "Sandy Fran "Kelly window [1] aisle *Sam" "Chris aisle "Alex** window middle "Pat" In writing assignGroup, you may call findBlock specified in part (b). Assume that findblock works as specified, regardless of what you wrote in part (b). Complete method assignGroup below. /** Assigns adjacent empty seats for a group of passengers Postcondition: if possible, assigns the group.size() Passengers from group to adjacent empty seats in a single row; Otherwise no changes are made. @return true if the group was assigned seats; false otherwise. */ public boolean assignGroup (List group)

Previous question

(c) You will write the Flight method assignGroup, which is described as

(c) You will write the Flight method assignGroup, which is described as follows. The parameter to the Flight method assignGroup is a list of passengers, group. These passengers require a block of adjacent seats in a single row. assignGroup searches for group.size() adjacent empty seats in some row. If such a block of seats is found, the passengers in group will be assigned to those seats, and assignGroup returns true. Otherwise, no passengers are assigned to seats, and assignGroup returns a false. For example, the seats in Flight ap324 are as shown in the first diagram below. If the array adults contains three passengers, the call ap314. assignGroup (adults) makes no changes to ap314 and returns false, because there is not block of three adjacent empty seats in a single row. On the other hand, suppose the array kids contains passengers "Sam" and "Alex". The call ap314.assignGroup (kids) will assign "Sam" and "Alex" to the seats shown in the second diagram below and return true. Contents of my Seats for ap314 before any call to assignGroup [0] [1] [0] window ******* "Kelly" window "Chris' [1] aisle * aisle www * [2] aisle "Sandy" aisle ********** [3] middle [2] aisle "Sandy" middle "Pat" Contents of my Seats for ap314 after call to ap314.assignGroup (kids) [0] [1] [3] window aisle middle [0] "Kelly" window aisle aisle middle [1] "Chris" "Sam "Alex" "Pat" [4] window "Fran" window [4] window ********** "Fran In writing assignGroup, you may call findBlock specified in part (b). Assume that findBlock works as specified, regardless of what you wrote in part (b). Complete method assignGroup below. window 40 /** Assigns adjacent empty seats for a group of passengers Postcondition: if possible, assigns the group.size() Passengers from group to adjacent empty seats in a single row; Otherwise no changes are made. @return true if the group was assigned seats; false otherwise. public boolean assignGroup (List group)

Step by Step Solution

3.31 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

java Assigns adjacent empty seats for a group of passengers Postcondition If possible assigns the groupsize passengers from group to adjacent empty seats in a single row Otherwise no changes are made ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!