In: Computer Science
Creat a theater booking system in java language using :
1.OOP objects -Classes
2.encapsulation
3.polymorphism
4.inheritance
5.abstract class
=================== simple java program for theater ticket booking ==================
import java.util.Scanner;
//class and encapsulation
class BookTheTicket {
private String movieName;
private String theatreName;
private int ticketCost;
void myAllmovies() {
System.out.println("-------Listing the movies:------");
System.out.println(" 1.DDLJ ------------ $40 \n 2.kkr---------$.50
\n 3.game-movie --------$60 \n 4.fun movie ----- $.70 ");
}
}
// inheritence
class theater extends BookTheTicket{
private int numOfTickets;
void theater() {
System.out.println("*******Listing the theatre:******* \n 1.coco
cola tld \n 2.koi gandhi kr");
int k;
int an;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n == 1) {
System.out.println("*******coco cola tld theater*******");
System.out.println("*******choose a movie name*******");
System.out.println("------Listing the movie:------\n 1.DDLJ \n
2.kkr ");
int monum = sc.nextInt();
if (monum == 1) {
System.out.println("DDLJ new movie @ coco cola tld theater");
System.out.println("Enter how many ticket to be booked:---");
int r = sc.nextInt();
int left= numOfTickets-r;
int amount=40*r;
System.out.println("press 1 to continue booking ticket----");
int h = sc.nextInt();
System.out.println("\n\n\n");
if (h == 1) {
System.out.println("******************************************************");
System.out.println("theater ------------------- coco cola tld
theater");
System.out.println("movie --------------------- DDLJ");
System.out.println("cost ---------------------- $"+amount);
System.out.println("******************************************************");
}
}
if (monum == 2) {
System.out.println("kkr @ coco cola tld theater");
System.out.println("Enter how many ticket to be booked:---");
int r = sc.nextInt();
int left= numOfTickets-r;
int amount=50*r;
System.out.println("press 1 to continue booking ticket----");
int h = sc.nextInt();
System.out.println("\n\n\n");
if (h == 1) {
System.out.println("******************************************************");
System.out.println("theater ------------------- coco cola
tld");
System.out.println("movie --------------------- kkr");
System.out.println("cost ---------------------- Rs"+amount);
System.out.println("******************************************************");
}
}
}
if (n == 2) {
System.out.println("*******koi gandhi kr theater*******");
System.out.println("*******choose a movie name*******");
System.out.println("------Listing the movie:------\n 1.DDLJ \n
2.kkr ");
int p = sc.nextInt();
int monum = sc.nextInt();
if (monum == 1) {
System.out.println("game-movie @ koi gandhi kr theater");
System.out.println("Enter how many ticket to be
booked:---");
int r = sc.nextInt();
int left= numOfTickets-r;
int amount=60*r;
System.out.println("press 1 to continue booking ticket----");
int h = sc.nextInt();
System.out.println("\n\n\n");
if (h == 1) {
System.out.println("******************************************************");
System.out.println("theater ------------------- koi gandhi
kr");
System.out.println("movie --------------------- game-movie");
System.out.println("cost ---------------------- Rs."+amount);
System.out.println("******************************************************");
}
}
if (monum== 2) {
System.out.println("fun movie @ koi gandhi kr theater");
System.out.println("Enter how many ticket to be booked:---");
int r = sc.nextInt();
int left= numOfTickets-r;
int amount=70*r;
System.out.println("press 1 to continue booking
ticket----");
int h = sc.nextInt();
System.out.println("\n\n\n");
if (h == 1) {
System.out.println("******************************************************");
System.out.println("theater ------------------- koi gandhi kr
");
System.out.println("movie --------------------- fun movie");
System.out.println("cost ---------------------- Rs."+amount);
System.out.println("******************************************************");
}
}
}
}
}
public class Main {
public static void main(String[] args) {
BookTheTicket ob1 = new BookTheTicket();
BookTheTicket [] moviename = new BookTheTicket[2];
moviename[0] = ob1;
theater ob2 = new theater();
moviename[1] = ob2;
System.out.println("@@@@@@@@@@ hello @@@@@@@@@@@@@
customer @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
System.out.println("---------1.list of movies and their
prices--------- \n-------2.acces and book tickets through
theaters---");
System.out.println("\n@@@@@@@@@@ thanks
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
Scanner d = new Scanner(System.in);
int h = d.nextInt();
switch (h) {
case 1: {
ob1.myAllmovies();
break;
}
case 2: {
ob2.theater();
}
}
}
}
------------------------------------------------------------------------------- end -----------------------------------------------------
=============== screenshots of the code and the output================================
======================== end ====================================================
===-------- PLEASE LIKE THE POST ----==========