import java.util.LinkedList; import java.util.Scanner; public class Agency { private Administrator loggedInUser; private Destinations destinations; private Flights flights;
Question:
import java.util.LinkedList;
import java.util.Scanner;
public class Agency {
private Administrator loggedInUser;
private Destinations destinations;
private Flights flights;
private Administrators admins;
public Agency() {
admins = new Administrators();
admins.insertDummyData();
destinations = new Destinations(this);
flights = new Flights(this);
}
public Destinations getDestinations() {
return destinations;
}
public Flights getFlights() {
return flights;
}
public void login() {
Scanner scanner = new Scanner(System.in);
boolean loggedIn = false;
while (!loggedIn) {
System.out.print("Username: ");
String username = scanner.nextLine();
System.out.print("Password: ");
String password = scanner.nextLine();
if (admins.validateCredentials(username, password)) {
loggedIn = true;
loggedInUser = new Administrator(admins.getAdminName(username), username, password);
mainMenu(scanner);
} else {
System.out.println("Invalid Credentials! Try Again.");
}
}
}
public void destinationsMenu(Scanner scanner) {
System.out.println("Welcome to the Destinations section " + loggedInUser.getName() + ", Please make a selection from the menu:");
while (true) {
System.out.println("1. View All Destinations");
System.out.println("2. View Destinations by Country");
System.out.println("3. Add a Destination");
System.out.println("4. Remove a Destination");
System.out.println("X. Return to Main Menu");
System.out.print("Please enter an option: ");
String option = scanner.nextLine();
switch (option) {
case "1":
destinations.displayAllDestinations();
break;
case "2":
break;
case "3":
break;
case "4":
break;
case "X":
mainMenu(scanner);
return;
default:
System.out.println("Please enter a valid choice, or press X to exit.");
}
}
}
public void mainMenu(Scanner scanner) {
System.out.println("Welcome to the Prog2 Travel Agency " + loggedInUser.getName() + ", Please make a selection from the menu:");
while (true) {
System.out.println("1. Explore Flights");
System.out.println("2. Explore Destinations");
System.out.println("3. Book a Trip");
System.out.println("X. Exit the System");
System.out.print("Please enter an option: ");
String option = scanner.nextLine();
switch (option) {
case "1":
break;
case "2":
destinationsMenu(scanner);
break;
case "3":
break;
case "X":
System.out.println("Thanks for using the Prog2 Travel Agency.");
System.exit(0);
default:
System.out.println("Please enter a valid choice, or press X to exit.");
}
}
}
public static void main(String[] args) {
Agency agency = new Agency();
agency.login();
}
}
public class Destination {
private String country;
private String name;
public Destination(String name, String country) {
this.name = name;
this.country = country;
}
public String getCountry() {
return country;
}
public String getName() {
return name;
}
}
import java.util.LinkedList;
public class Destinations {
private LinkedList destinations;
private Agency agency;
public Destinations(Agency agency) {
this.agency = agency;
destinations = new LinkedList<>();
destinations.add(new Destination("Eiffel Tower", "France"));
destinations.add(new Destination("Opera House", "Australia"));
destinations.add(new Destination("Uluru", "Australia"));
destinations.add(new Destination("Machu Picchu", "Peru"));
destinations.add(new Destination("Great Pyramids", "Egypt"));
destinations.add(new Destination("Niagara Falls", "Canada"));
}
public LinkedList getAllDestinations() {
return destinations;
}
public LinkedList getDestinationsByCountry(String country) {
LinkedList result = new LinkedList<>();
for (Destination dest : destinations) {
if (dest.getCountry().equalsIgnoreCase(country)) {
result.add(dest);
}
}
return result;
}
public void displayAllDestinations() {
System.out.println("+----------------------+----------------+--------------+-------+-------+");
System.out.println("| Destinations |");
System.out.println("+----------------------+----------------+--------------+-------+-------+");
for (Destination destination : destinations) {
System.out.println(destination.getName() + " in " + destination.getCountry());
}
System.out.println("+----------------------+----------------+--------------+-------+-------+");
}
}
the login works i need help using the untils to header and footer and also with the test case above.
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts