The ticketing system at the airport is broken, and passengers have lined up to board the plane in the incorrect order. This line is represented in an ArrayList tickets in the AirLineTester class. Devise a way to separate passengers into the correct boarding groups. Currently, there is an AirlineTicket class that holds the information for each passengers ticket. They have a name, seat, row, and boarding group. Use the TicketOrganizer class to help fix the order of passengers boarding. First, create a constructor that takes an ArrayList of AirLineTickets and copies it to a class variable ArrayList. Then, create a getTickets method to get the ArrayList of AirLineTickets. In the TicketOrganizer class, create a method called printPassengersByBoardingGroup that prints out the name of the passengers organized by boarding group. The boarding groups go from 1-5, and have been predetermined for you. This should print the boarding group followed by all passengers in the group:

Answers

Answer 1
Answer:

Answer:

See explaination

Explanation:

The program code

import java.util.ArrayList;

public class Main

{

public static void main(String[] args)

{

ArrayList<AirlineTicket> tickets = new ArrayList<AirlineTicket>();

//This creates a randomized list of passengers

addPassengers(tickets);

for(AirlineTicket elem: tickets)

{

System.out.println(elem);

}

//This creates a TicketOrganizer object

TicketOrganizer ticketOrganizer = new TicketOrganizer(tickets);

//These are the methods of the ticketOrganizer in action

System.out.println("\nPassengers Ordered by Boarding Group:");

ticketOrganizer.printPassengersByBoardingGroup();

System.out.println("\nPassengers in line who can board together:");

ticketOrganizer.canBoardTogether();

}

//Do not touch this method! It is adding random passengers to the AirlineTicket array

public static void addPassengers(ArrayList<AirlineTicket> tickets)

{

String[] seats = {"A","B","C","D","E","F"};

for(int index = 0; index< 15; index++)

{

int random = (int)(Math.random() * 5);

AirlineTicket ticket = new AirlineTicket("Passenger " + (index+1), seats[random], ((int)(Math.random()*5)+1), ((int)(Math.random()*8)+1));

tickets.add(ticket);

}

}

}

class TicketOrganizer

{

private ArrayList<AirlineTicket> tickets ;

//constructor with parameter as an arraylist of AirlineTicket

public TicketOrganizer(ArrayList<AirlineTicket> tickets)

{

this.tickets = tickets;

}

//methhods to return the arraylist of airlines

public ArrayList<AirlineTicket> getTickets()

{ //re-organize the ticket first

ArrayList<AirlineTicket> tickets_organized = new ArrayList<AirlineTicket>();

for(int i=1; i<=5; i++)

{

for(AirlineTicket ticket: tickets)

{

if(ticket.getBoardingGroup() == i)

{

tickets_organized.add(ticket);

}

}

}

return tickets_organized;

}

//print the tickets based on boardingGroup

public void printPassengersByBoardingGroup()

{

int count = 0;

for(int i=1; i<=5; i++)

{

System.out.println("Boarding Group " + i + ":");

for(AirlineTicket ticket : tickets)

{

if(ticket.getBoardingGroup() == i)

{

System.out.println("Passenger " + ticket.getName());

}

}

}

See attachment for sample output


Related Questions

A teacher at your school is using her district issued laptop to create spreadsheets for her part-time job as a bookkeeper. Which standard, if any, is this teacher violating?
Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as input the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is
The function changeLocation is also called a _____.class bike:def __init__(self,size,idNum,color ):self.size = sizeself.location = 10self.color = colorself.idNum = idNumdef changeLocation(self,newLocation):self.location = newLocationmanipulatorinitiatormethodconstructor
DSL is the abbreviation for?data service linedigital subscriber linedata subscriber linedigital service linenone of the above
What is time-slice? How is the end of the time slice indicated?

When you move or size a control in the Form Designer, Visual Studio automatically adjusts the ________________ that specify the location and size of the control.

Answers

Answer:

When you move or size a control in the Form Designer, Visual Studio automatically adjusts the properties that specify the location and size of the control.

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side

Answers

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

In a company you are in charge of system maintainance. Justify with 5 reasons why your role is key

Answers

Answer:

As u are the in charge of system maintainance u have to maintain safety and security to the system.as the system maintainance is a very big role and u can say it is the key to ur company or to ur work.

)when you classify data into groups and subgroups you are using a(n) ____ order?A. Circular

B. Hierarchical

C. Linear

D. Group

Answers

Answer:B)Hierarchical

Explanation: Hierarchical order classifies the distribution of the data into the groups and their subgroups .The division of these groups and subgroups appear in the structure of pyramid generally.

The classification done in the hierarchical order is based on the authority on each level e.g.-the level with high authority is situated at higher level and below it, followed by its subgroup components.So, the correct option is option(B).

Change the screen resolution so you can view more information on your screen. Use the resolution that enables you to fit the most information on the screen while still being able to read the display.Use the space below to indicate your screen resolution and to describe the steps you used to do this.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

My laptop's current screen resolution is (1366 by 768 recommended). When you change your screen resolution, your pc automatically suggests the recommended screen resolution that helps you to view more information on your screen and enable you to fit the most information on the screen while still being able to read the display.

To change the screen resolution, you need to go through from the following steps:

  1. Right-click on empty space of desktop.
  2. As you right-click, a list of options will open, select "display setting" among them
  3. A new setting window will get open, at the left of the window, among given option, click on the first option i.e "display"
  4. The content of the display setting gets open in the right area of the window. scroll down and find the "Scale and Layout"
  5. under scale and layout, you can change your screen resolution while selecting the different screen resolution. However, it is good to select the recommended screen resolution based on your screen size.

Illustrator : how do you edit a swatch ?​

Answers

Answer:

To edit an existing pattern, double-click the pattern in the pattern swatch, or select an object containing the pattern and choose Object > Pattern > Edit Pattern