Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image

(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

Step: 1

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management And Organisational Behaviour

Authors: Laurie Mullins

7th Edition

0273688766, 978-0273688761

More Books

Students also viewed these Programming questions

Question

Distinguish between random events and fixed events.

Answered: 1 week ago

Question

Which in your opinion is the most crucial stage?

Answered: 1 week ago

Question

5. Can an inhibitory message propagate along an axon?

Answered: 1 week ago