1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
expeople1 [14]
3 years ago
6

You should also create a method named canBoardTogether which determines if passengers already in line in the tickets ArrayList c

an board with the people they are standing next to in line. If a passenger has the same row and boarding group as the person behind them, this method should print that those two passengers can board together. For instance if Passenger 11 and Passenger 12 are both in Row 3, and in Boarding Group 4, the method would print:
Computers and Technology
1 answer:
qaws [65]3 years ago
3 0

Answer:

See explaination

Explanation:

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());

}

}

}

}

//check if two persons can sit together

public void canBoardTogether()

{

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

{

String str = "Passenger "+ (i + 1) +" can board with Passengers";

for(int j=i+1; j<14; j++)

{

boolean isRowEqual = tickets.get(i).getRow() == tickets.get(j).getRow();

boolean isBoardGroupEqual = tickets.get(i).getBoardingGroup() == tickets.get(j).getBoardingGroup();

//if one of them false, print the all added Passengers

if(!(isRowEqual && isBoardGroupEqual))

{

if(j != i+1)

{

System.out.println(str);

}

break;

}

str += " " + (j+1);

}

}

}

}

class AirlineTicket

{

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

private String name;

private String seat;

private int boardingGroup;

private int row;

public AirlineTicket(String name, String seat, int boardingGroup, int row)

{

this.name = name;

if(isValidSeat(seat))

{

this.seat = seat;

}

this.boardingGroup = boardingGroup;

this.row = row;

}

private boolean isValidSeat(String seat)

{

boolean isValidSeat = false;

for(String elem: seats)

{

if(seat.equals(elem))

{

isValidSeat = true;

}

}

return isValidSeat;

}

public String getSeat()

{

return this.seat;

}

public String getName()

{

return this.name;

}

public int getBoardingGroup()

{

return this.boardingGroup;

}

public int getRow()

{

return this.row;

}

public String toString()

{

return name + " Seat: " +seat + " Row: " + row + " Boarding Group: " + boardingGroup;

}

}

You might be interested in
In which situation is coauthoring of presentations primarily utilized?
fenix001 [56]

Answer:

C) Multiple reviewers have to be able to view one another's changes after they are made.

Explanation:

5 0
3 years ago
A ___ is an online collaborative event that may include such features as chat, slideshows, and PowerPoint presentations.
german

Answer:

I think Microsoft Teams

Explanation:

Microsoft Teams. Teams is a chat-based collaboration tool that provides global, remote, and dispersed teams with the ability to work together and share information via a common space. You can utilize cool features like document collaboration, one-on-one chat, team chat, and more. Microsoft Teams is also fully integrated with many other Office 365 services, such as Skype, SharePoint, Exchange, and Yammer.

5 0
3 years ago
Choose ALL guidelines listed below pertaining to fair use.
tino4ka555 [31]

Answer:

Introduction

As you write blog posts, you may find that you want to include images you find online. Or maybe you found a great piece of writing—a recipe, a story, or a review—that you want to highlight on your own blog. It's important to know that almost all of the content you find on the Web belongs to someone. Just because you can take images, text, and more from other sites doesn't mean it's right to do so—ethically or legally.

In this lesson, you'll learn about the copyright protections that apply to work posted online. You'll learn about the rules that determine which images and text you can use, and how you can use them. You'll also learn how to protect the content you create.

The laws discussed in this lesson are United States laws. No lawyer was involved in preparing this lesson. We are not legal experts, and this lesson should not be taken as legal advice.

Understanding copyright

Copyright is the legal concept that works—art, writing, images, music, and more—belong to the people who create them. According to copyright law, any original content you create and record in a lasting form is your own intellectual property. This means other people can't legally copy your work and pretend it's their own. They can't make money from the things you create either.

To use, copy, or change a copyrighted work, you need permission from the person who holds the copyright. This permission is called a license. Even though everyone has the right to require that others respect their copyright and ask permission to use their work, some people and organizations choose to license their content more freely. They do this by giving their work a Creative Commons license or by placing their work in the Public Domain.

6 0
3 years ago
Read 2 more answers
How to cite a dictionary in mla 8 owl perdue?
Elan Coil [88]
<span>To cite an entry in a dictionary according to Purdue Owl MLA 8th generation, you would cite it as any other book but do not include the publisher or the volume (if arranged alphabetically. An example is: "Creation" The American Heritage Dictionary. 3rd ed., 1997.</span>
6 0
3 years ago
The total number of errors divided by the total number of bits transmitted is the definition of __________. committed informatio
kodGreya [7K]

The answer in the blank is bit error rate, for it is where errors usually occurs and this happens during the digital data transmission. Because of the errors that it is being managed, it divides those errors by the total number of bits that are being transmitted during the process. It happens within a given period.

8 0
4 years ago
Other questions:
  • Defination of computer Software​
    7·2 answers
  • Which of the following is the largest disadvantage of wind power?
    12·2 answers
  • Which of the following is an advantage to using plain text format? Check all of the boxes that apply.
    15·2 answers
  • The term _______ is used to refer to programs that attackers install after gaining unauthorized access to a system, ensuring tha
    15·1 answer
  • Francis has created a new program. However, Francis used some objects from another program to run methods in the current program
    14·2 answers
  • Open IDLE. Create a new script file (File--&gt;New File, Ctrl n on Windows, Cmd n on macOS). On the first line, place your name
    6·1 answer
  • 1. Define Validation Rule
    14·1 answer
  • 50 POINTS
    6·1 answer
  • Hannah wanted to watch a movie. She typed the movie name on the search engine. In result she found the downloadable link of the
    10·1 answer
  • Write a program that accepts three decimal numbers as input and outputs their sum.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!