CS 2421 Object Oriented Programming in Java
  • CS 2421 Object Oriented Programming in Java
  • Module 1
    • Presentations
    • Lecture Videos
    • Source Code
    • Assignment
  • Module 2
    • Presentations
    • Lecture Videos
    • Source Code
    • Assignment
  • Module 3
    • Presentations
    • Lecture Videos
    • Source Code
    • Assignment
  • Module 4
    • Presentations
    • Lecture Videos
    • Source Code
    • Assignment
  • Module 5
    • Presentations
    • Videos
    • Source Code
    • Assignment
  • Module 6
    • Presentations
    • Videos
    • Source Code
    • Assignment
Powered by GitBook
On this page
  • M4Assignment1.java
  • TheaterManagement.java
  1. Module 4

Assignment

M4Assignment1.java

import java.util.*;

public class M4Assignment1 {
    public static void main(String[] args) {
        System.out.println("Module 4 Assignment 1");
        // Create new Scanner object (don't delete!)
        Scanner in = new Scanner(System.in);
        // menu variables
        boolean done = false;
        String choice;
        // do while menu loop
        do {
            System.out.println("P1 - Problem 1");
            System.out.println("P2 - Problem 2");
            System.out.println("P3 - Problem 3");
            System.out.println("P4 - Problem 4");
            System.out.println("P5 - Problem 5");
            System.out.println("P6 - Problem 6");
            System.out.println("P7 - Problem 7");
            System.out.println("P8 - Problem 8");
            System.out.println("Q - Quit");
            System.out.print("Choice: ");
            choice = in.nextLine();
            switch (choice) {
                case "P1":
                    System.out.println("Problem 1");
                    
                    break;
                case "P2":
                    System.out.println("Problem 2");
                    
                    break;
                case "P3":
                    System.out.println("Problem 3");

                    break;
                case "P4":
                    System.out.println("Problem 4");

                    break;
                case "P5":
                    System.out.println("Problem 5");

                    break;
                case "P6":
                    System.out.println("Problem 6");

                    break;
                case "P7":
                    System.out.println("Problem 7");

                    break;
                case "P8":
                    System.out.println("Problem 8");

                    break;
                // quit and default cases
                case "Q":
                    System.out.println("Quit");
                    done = true;
                    break;
                default:
                    System.out.println("Invalid Choice");
                    break;
            }
        } while (!done);

        // close the Scanner (don't delete!)
        in.close();
    }
    // problem1 method
    
    // problem2 method

    // problem3 method
    

}

TheaterManagement.java

import java.util.*;

/**
 * Provides functionalities to manage a theater's seating arrangement, including displaying the seating grid,
 * checking seat pricing, purchasing seats, calculating revenue, and determining the percentage of sold seats.
 */
public class TheaterManagement {

    /**
     * Main method serving as the entry point of the application. It initializes the seating array
     * and processes user inputs through a console-based menu using a do-while loop.
     *
     * @param args command line arguments (not used)
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        // Create theater seats and prices
        int[][] seats = {

        };

        do {
            System.out.println("G - Show Theater Grid");
            System.out.println("S - Seat Pricing");
            System.out.println("P - Purchase Seat");
            System.out.println("R - Revenue");
            System.out.println("C - Calculate Sold Seats Percentage");
            System.out.println("Q - Quit");
            System.out.print("Choice: ");
            String choice = in.nextLine().toUpperCase();
            switch (choice) {
                case "G":
                    showTheaterGrid(seats);
                    break;
                case "S":
                    showSeatPricing(seats, in);
                    break;
                case "P":
                    purchaseSeat(seats, in);
                    break;
                case "R":
                    showRevenue(seats);
                    break;
                case "C":
                    showSoldSeatsPercentage(seats);
                    break;
                case "Q":
                    return; // Exit the program
                default:
                    System.out.println("Invalid choice. Please try again.");
                    break;
            }
        } while (true);
    }

    /**
     * Displays the theater seating grid, indicating seat prices and marking purchased seats with an 'X'.
     *
     * @param seats The 2D array representing the theater seats and their prices or purchase statuses.
     */
    private static void showTheaterGrid(int[][] seats) {

    }

    /**
     * Allows the user to check the pricing of a specific seat by entering its row and column numbers.
     *
     * @param seats The 2D array representing the theater seats and their prices.
     * @param in The Scanner object for user input.
     */
    private static void showSeatPricing(int[][] seats, Scanner in) {

    }

    /**
     * Processes the purchase of a seat, marking it as sold (0) in the seating array if available.
     *
     * @param seats The 2D array representing the theater seats and their prices or purchase statuses.
     * @param in The Scanner object for user input.
     */
    private static void purchaseSeat(int[][] seats, Scanner in) {

    }

    /**
     * Calculates and displays the total revenue generated from the sold seats.
     *
     * @param seats The 2D array representing the theater seats and their prices or purchase statuses.
     */
    private static void showRevenue(int[][] seats) {

    }

    /**
     * Calculates and displays the percentage of seats that have been sold.
     *
     * @param seats The 2D array representing the theater seats and their prices or purchase statuses.
     */
    private static void showSoldSeatsPercentage(int[][] seats) {

    }
}
PreviousSource CodeNextPresentations

Last updated 1 year ago