Question

Complete and correct answer is required to give full credit,thank you Consider the following set of...

Complete and correct answer is required to give full credit,thank you

Consider the following set of requirements for an airline database that is used to keep track of flights, passengers, employees etc. for an airline. You will be graded not only on the correctness and completeness of the design but also on its quality.

1)     It is important to keep track of each passenger's name, address, phone number and meal preference (values could be vegetarian, sea-food, italian, anything). At times, it becomes necessary to refer to the city, state, and zip of the passenger's address.

2)     Each flight is described by its number, dep_city, arr_city, dep_time and arr_time. For this assignment, we will assume that all entries in the database are direct flights only. The flights are uniquely identified by their number.

3)     Obviously, it is important to keep track of all airline personnel. For each person, we need to keep track of the unique employee number, name, address and salary.

4)     The airline keeps track of all departures for one year. For each departure, we need to have the date of departure, the flight that it represents, all personnel who are going to be assigned to it, and all passengers that are booked on it.

5)     For each type of plane in the whole world, the airline wants to keep track of its model number and manufacturer. For example, the manufacturer of a plane whose model number is 747 is Boeing Corporation.

6)     Each aircraft owned and operated by the airline is assigned a unique serial number, and the airline keeps track of what type of plane it is. For example, serial # of a specific plane may be A1234 and type may be 747. Each departure is assigned a specific aircraft owned by the company.

7)     There is a select group of personnel called pilots for whom the information about which types of planes can they fly along with the date when they received their pilot licenses is kept.

Design an ER schema for this application, and draw an ER diagram for that schema. Specify key attributes of each entity type and structural constraints on each relationship type. Specify the structural constraints using partial/total participation and specification of cardinality ratio. If you find that the specifications are incomplete, then make appropriate assumptions and document them precisely. Do a complete job.

Homework Answers

Answer #1

import java.io.*;

import java.util.*;

public class Airline {

    /**

     * The number of seats on the plane

     */

    static final int MAX_SEATS = 8;

public Airline() {

    }

    public void main(String[] args) {

        boolean done = false;

        String[] seats = new String[MAX_SEATS];     // the passenger list

        initializeSeats(seats);

        do {

            printMainMenu();

            int choice = getMainMenuChoice();       // choice off of the main menu

            switch (choice) {

            case 1:

                makeReservation(seats);

                break;

            case 2:

                cancelReservation(seats);

                break;

            case 3:

                printSeatingChart(seats);

                break;

            case 4:

                done = true;

                break;

            }

        } while (!done);

    }

//CONSOLE

public class Console {

    private BufferedReader in;

    private String integerReprompt = "Invalid integer. Try again: ";

    private String doubleReprompt = "Invalid double. Try again: ";

    private String charReprompt = "Invalid character. Try again: ";

     {

        in = new BufferedReader(new InputStreamReader(System.in));

    }

    public String readString() {

        String s = null;

            s = in.readLine();

        return s;

    }

    public char readChar() {

        char c = 0;

            String s = in.readLine();

                if (s.length() == 1) {

                    c = s.charAt(0);

                    valid = true;

                } else {

                    System.out.print(charReprompt);

                }

        return c;

    }

    int readInt() {

        int i = 0;

            boolean valid = false;

                    i = Integer.parseInt(in.readLine());

                    valid = true;

                    System.out.print(integerReprompt);

        return i;

    }

    public double readDouble() {

        double d = 0.0;

        boolean valid = true;

                    d = Double.parseDouble(in.readLine());

                    valid = true;

                    valid = false;

                    System.out.print(doubleReprompt);

        return d;

    }

    public void pause() {

            System.out.print("Press enter to continue...");

            in.readLine();

        }

    public void setIntegerReprompt(String prompt) {

        integerReprompt = prompt;

    }

    public void setDoubleReprompt(String prompt) {

        doubleReprompt = prompt;

    }

    public void setCharReprompt(String prompt) {

        charReprompt = prompt;

    }

}

//END CONSOLE

    /**

     * Print the main menu

     */

    void printMainMenu() {

        System.out.println("\nMain Menu\n");

        System.out.println("1. Make a reservation");

        System.out.println("2. Cancel a reservation");

        System.out.println("3. Print seating chart");

        System.out.println("4. Quit");

        System.out.println();

    }

    /**

     * Get the user's choice off the main menu

     */

    int getMainMenuChoice() {

        int choice;             // choice entered

        boolean valid = false; // is choice valid?

        do {

            System.out.print("===> ");

            choice = Console.readInt();

            if (1 <= choice && choice <= 4) {

                valid = true;

            } else {

                System.out.println("Invalid choice.");

            }

        } while (!valid);

        return choice;

    }

    /**

     * Initialize each element of seats to the empty string

     */

    void initializeSeats(String[] seats) {

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

            seats[i] = "";

        }

    }

    /**

     * Make a reservation

     */

    void makeReservation(String[] seats) {

        int seatIndex = findEmptySeat(seats);   // index of first empty seat

        if (seatIndex == seats.length) {

            System.out.println("All seats are full. Sorry.");

        } else {

            String name = getPassengerName();   // passenger's name

            seats[seatIndex] = name;

            System.out.println(name + " has been assigned seat #" + (seatIndex+1));

        }

    }

    /**

     * Cancel a reservation

     */

    void cancelReservation(String[] seats) {

        int seatIndex = getSeatToCancel();      // index of seat to cancel reservation for

        if (isEmpty(seats, seatIndex)) {

            System.out.println("Seat #" + (seatIndex+1) + " has not been reserved for anyone");

        } else {

            seats[seatIndex] = "";

            System.out.println("Seat #" + (seatIndex+1) + " is now available");

        }

    }

    /**

     * Print the seating chart

     */

    void printSeatingChart(String[] seats) {

        System.out.println("\nSeating Chart\n");

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

            System.out.println((i+1) + ". " + seats[i]);

        }

    }

    /**

     * Find the index of the first empty seat on the plane.

     * If there are no empty seats, return seats.length

     */

    int findEmptySeat(String[] seats) {

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

            if (isEmpty(seats, i)) {

                return i;

            }

        }

        return seats.length;

    }

    /**

     * Yield whether seats[seatIndex] is an empty seat.

     */

    boolean isEmpty(String[] seats, int seatIndex) {

        return seats[seatIndex].equals("");

    }

    /**

     * Input a passenger's name

     */

    String getPassengerName() {

        System.out.print("Enter the passenger's name: ");

        return Console.readString();

    }

    /**

     * Input the number of a seat to cancel, return the

     * index of that seat.

     */

    int getSeatToCancel() {

        boolean valid = false; // is the seat number valid?

        int seat;               // seat number to cancel

        do {

            System.out.print("Enter the seat to cancel: ");

            seat = Console.readInt();

            if (1 <= seat && seat <= MAX_SEATS) {

                valid = true;

            } else {

                System.out.println("Invalid seat number");

            }

        } while (!valid);

        return seat-1;

    }

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT