TEST- Chương trình quản lý rạp chiếu film bằng java
Rạp chiếu phim quốc gia hiện nay đang cần thiết kế 1 chương trình nhằm kiểm soát toàn bộ hoạt động tại rạp bào gồm
- Quầy bán vé (ticket counter) => gồm các trạng thái (trống, khách hàng ít, khách hàng vừa phải và đang rất đông, thời điểm)
- Bãi đỗ xe (Parking) => gồm các trạng thái (trống, ít, vừa phải, full, thời điểm)
- Phòng xem phim => gồm các thuộc tính số ghế, số ghế đang ngồi, thời điểm
- Quầy bán đồ ăn => gồm các trạng thái (trống, khách hàng ít, khách hàng vừa phải và đang rất đông, thời điểm)
Viết chương trình quản lý thực hiện các yêu cầu sau
- Tạo 1 giao diện IStatus => có 1 phương thức onStatus => làm nhiệm vụ hiển thị trạng thái của từng địa điểm
- Thiết kế các lớp đối tượng trên => kế thừa từ IStatus
- Thiết kế các hàm nhập, hiển thị cho từng đối tượng trên
Trong class Main
- Nhập thông tin gồm 3 quầy bán vé, 2 quầy bán đồ ăn, 2 bãi đỗ xe và 5 phòng chiếu phim
- Tạo 1 phương thức followStatus(List<IStatus> statusList) thực hiện hiển thị trạng thái của tất cả các địa điểm => yêu cầu sử dụng hàm này cho >>> 3 quầy bán vé, 2 quầy bán đồ ăn, 2 bãi đỗ xe và 5 phòng chiếu phim >> trong chương trình trên
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Đỗ Văn Huấn [T1907A]](https://www.gravatar.com/avatar/04c40301dd027839d265b3c3c9dc6e6b.jpg?s=80&d=mm&r=g)
Đỗ Văn Huấn
2020-03-16 15:30:23
package BaiTapNgay16_3_2020.Cinema; |
package BaiTapNgay16_3_2020.Cinema; |
package BaiTapNgay16_3_2020.Cinema; |
package BaiTapNgay16_3_2020.Cinema; |
package BaiTapNgay16_3_2020.Cinema; |
package BaiTapNgay16_3_2020.Cinema; |
![Đường Thanh Bình [T1907A]](https://www.gravatar.com/avatar/c2ef7c316acb82467912bf5677b52a8b.jpg?s=80&d=mm&r=g)
Đường Thanh Bình
2020-03-16 14:35:32
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Film;
import java.util.ArrayList;
/**
*
* @author Administrator
*/
public class Main {
public static void main(String[]agrs){
ArrayList<IStatus> statusList;
statusList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
int s = i+1;
System.out.println("phòng vé thứ " + s +" :\n");
ticket_Counter t1 = new ticket_Counter();
t1.input();
statusList.add((IStatus) t1);
}
do_an d1 = new do_an();
d1.input();
statusList.add(d1);
do_an d2 = new do_an();
d2.input();
statusList.add(d2);
Parking p1 = new Parking();
p1.input();
statusList.add((IStatus) p1);
Parking p2 = new Parking();
p2.input();
statusList.add((IStatus) p2);
for (int i = 0; i < 5; i++) {
watching w = new watching();
w.input();
statusList.add(w);
}
for (IStatus iStatus : statusList) {
iStatus.onStatus();
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Film;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class do_an implements IStatus{
static enum Status{
Empty,it_khach,vua_phai,rat_dong
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Empty;
break;
case 2:
status = Status.it_khach;
break;
case 3:
status = Status.vua_phai;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Empty:
System.out.println(">>>vắng khách");
break;
case it_khach:
System.out.println(">>>khách hàng it");
break;
case vua_phai:
System.out.println(">>>Lượng khách vừa phải");
break;
case rat_dong:
System.out.println(">>>Đang rất đông");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Film;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Parking {
static enum Status{
trong , it , vua , full
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.Còn ít chỗ");
System.out.println("3.Bình thường");
System.out.println("4.Hết chỗ");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.trong;
break;
case 2:
status = Status.it;
break;
case 3:
status = Status.vua;
break;
case 4:
status = Status.full;
break;
default:
break;
}
}
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case trong:
System.out.println(">>>Trống");
break;
case it:
System.out.println(">>>Còn ít chỗ");
break;
case vua:
System.out.println(">>> bình thường");
break;
case full:
System.out.println(">>> Hết chỗ");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Film;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class watching implements IStatus {
int tong_ghe;
int da_dung_ghe;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Tổng ghế ");
tong_ghe = Integer.parseInt(scan.nextLine());
for(;;){
System.out.println("Số ghế đang dùng : ");
da_dung_ghe = Integer.parseInt(scan.nextLine());
if (da_dung_ghe > tong_ghe) {
System.out.println("Số ghế đang dùng không đc lớn hơn tổng số ghế ");
}else{
break;
}
}
System.out.println("Thời điểm : ");
thoi_diem = scan.nextLine();
}
@Override
public void onStatus() {
System.out.println("Tổng số ghế : "+tong_ghe);
System.out.println("Số ghế đã dùng : "+da_dung_ghe);
System.out.println("Thời điểm : "+thoi_diem);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Film;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class ticket_Counter implements IStatus {
static enum Status {
Trong, It_Khach, binh_thuong, rat_dong;
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Trong;
break;
case 2:
status = Status.It_Khach;
break;
case 3:
status = Status.binh_thuong;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Trong:
System.out.println(">>> Trống");
break;
case It_Khach:
System.out.println(">>> khách hàng it");
break;
case binh_thuong:
System.out.println(">>> Khách hàng vừa phải");
break;
case rat_dong:
System.out.println(">>> Đang rất đông");
break;
default:
break;
}
}
}
![Phí Văn Long [T1907A]](https://www.gravatar.com/avatar/5db166b7b74443c5c221e4c0068d6da9.jpg?s=80&d=mm&r=g)
Phí Văn Long
2020-03-16 14:18:46
Main:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
import java.util.ArrayList;
/**
*
* @author Nongnek
*/
public class Main {
public static void main(String[] args) {
ArrayList<IStatus> listStatus = new ArrayList<>();
inputStatus(listStatus);
followStatus(listStatus);
}
public static void inputStatus(ArrayList<IStatus> listStatus) {
for (int i = 0; i < 3; i++){
System.out.println("Phong ban ve thu: " + (i+1) + ": ");
TicketCounter ticket = new TicketCounter();
ticket.input();
listStatus.add(ticket);
}
for (int i = 0; i < 2; i++) {
System.out.println("Quay do an thu: " + (i+1) + ": ");
Food food = new Food();
food.input();
listStatus.add(food);
}
for (int i = 0; i < 2; i++) {
System.out.println("Bai do xe thu: " + (i+1) + ": ");
Parking parking = new Parking();
parking.input();
listStatus.add(parking);
}
for (int i = 0; i < 5; i++) {
System.out.println("Phong chieu phim so: " + (i+1) + ": ");
Watching watching = new Watching();
watching.input();
listStatus.add( watching );
}
}
public static void followStatus(ArrayList<IStatus> listStatus){
for(IStatus iStatus: listStatus){
iStatus.onStatus();
}
}
}
IStatus:/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
/**
*
* @author Nongnek
*/
public interface IStatus {
public void onStatus();
}
TicketCounter:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
import java.util.Scanner;
/**
*
* @author Nongnek
*/
public class TicketCounter implements IStatus {
static enum Status {
Trong, KhachHangIt, KhachHangVuaPhai, KhachHangRatDong;
};
Status sts;
String ThoiDiem;
public void input() {
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Nhap thoi diem: ");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. Khach hang it");
System.out.println("3. Khach hang vua phai");
System.out.println("4. Khach hang rat dong");
System.out.print("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
System.out.println("Trong");
break;
case 2:
sts = Status.KhachHangIt;
System.out.println("Khach hang it");
break;
case 3:
sts = Status.KhachHangVuaPhai;
System.out.println("Khach hang vua phai");
break;
case 4:
sts = Status.KhachHangRatDong;
System.out.println("Dang rat dong");
break;
default:
System.out.println("Nhap sai nhap lai di ban eii. Bo ra ban eii");
break;
}
}
@Override
public void onStatus(){
System.out.print("\n Thoi diem : "+ThoiDiem);
}
}
Watching:/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
import java.util.Scanner;
/**
*
* @author Nongnek
*/
public class Watching implements IStatus{
int TatCaGhe;
int GheDangDung;
String ThoiDiem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Tat ca ghe: ");
TatCaGhe = Integer.parseInt(scan.nextLine());
for(;;){
System.out.println("So ghe dang su dung : ");
GheDangDung = Integer.parseInt(scan.nextLine());
if (GheDangDung > TatCaGhe) {
System.out.println("So ghe dang dung phai nho hon tong so ghe ");
}else{
break;
}
}
System.out.println("Thoi diem : ");
ThoiDiem = scan.nextLine();
}
@Override
public void onStatus() {
System.out.println("Watching:");
System.out.println("Tat ca ghe: "+TatCaGhe);
System.out.println("So ghe dang su dung: "+GheDangDung);
System.out.println("Thoi diem: "+ThoiDiem);
}
}
Parking:/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
import java.util.Scanner;
/**
*
* @author Nongnek
*/
public class Parking implements IStatus {
static enum Status {
Trong, It, VuaPhai, Full;
};
Status sts;
String ThoiDiem;
public void input(){
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Thoi Diem:");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. It");
System.out.println("3. Vua phai");
System.out.println("4. Full");
System.out.println("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
System.out.println("Trong");
break;
case 2:
sts = Status.It;
System.out.println("Con it cho");
break;
case 3:
sts = Status.VuaPhai;
System.out.println("Con vua phai cho");
break;
case 4:
sts = Status.Full;
System.out.println("Het cho");
break;
default:
System.out.println("Nhap sai nhap lai di");
break;
}
}
@Override
public void onStatus() {
System.out.println("Parking;");
System.out.print("Thoi Diem: "+ThoiDiem);
}
}
Food:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package QuanLiRapChieuPhim;
import java.util.Scanner;
/**
*
* @author Nongnek
*/
public class Food implements IStatus{
static enum Status {
Trong, KhachHangIt, KhachHangVuaPhai, KHDangRatDong;
};
Status sts;
String ThoiDiem;
public void input() {
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Thoi Diem:");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. Khach hang it");
System.out.println("3. Khach hang vua phai");
System.out.println("4. Dang rat dong");
System.out.print("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
System.out.println("Trong");
break;
case 2:
sts = Status.KhachHangIt;
System.out.println("Khach hang it");
break;
case 3:
sts = Status.KhachHangVuaPhai;
System.out.println("Khach hang vua phai");
break;
case 4:
sts = Status.KHDangRatDong;
System.out.println("Khach Hang Dang Rat Dong");
break;
default:
System.out.println("**o hieu kieu gi");
break;
}
}
@Override
public void onStatus() {
System.out.println("Food:");
System.out.print("Thoi diem : "+ThoiDiem);
}
}
![lê văn phương [T1907A]](https://www.gravatar.com/avatar/a07ddfb51e1e7189c76b4e42dbdbcddc.jpg?s=80&d=mm&r=g)
lê văn phương
2020-03-16 13:44:58
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rapphim;
import java.util.ArrayList;
/**
*
* @author HOME
*/
public class Main {
public static void main(String[] args) {
ArrayList<IStatus> statusList;
statusList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
int s = i+1;
System.out.println("phòng vé thứ " + s +" :\n");
quayve t1 = new quayve();
t1.input();
statusList.add(t1);
}
quaybandoan d1 = new quaybandoan();
d1.input();
statusList.add(d1);
quaybandoan d2 = new quaybandoan();
d2.input();
statusList.add(d2);
BaiDoXe p1 = new BaiDoXe();
p1.input();
statusList.add((IStatus) p1);
BaiDoXe p2 = new BaiDoXe();
p2.input();
statusList.add((IStatus) p2);
for (int i = 0; i < 5; i++) {
rapphim w = new rapphim();
w.input();
statusList.add(w);
}
for (IStatus iStatus : statusList) {
iStatus.onStatus();
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rapphim;
import java.util.List;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class quayve implements IStatus{
static enum Status {
Trong, It_Khach, binh_thuong, rat_dong;
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Trong;
break;
case 2:
status = Status.It_Khach;
break;
case 3:
status = Status.binh_thuong;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Trong:
System.out.println(">>> Trống");
break;
case It_Khach:
System.out.println(">>> khách hàng it");
break;
case binh_thuong:
System.out.println(">>> Khách hàng vừa phải");
break;
case rat_dong:
System.out.println(">>> Đang rất đông");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rapphim;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class BaiDoXe {
static enum Status{
trong , it , vua , full
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.Còn ít chỗ");
System.out.println("3.Bình thường");
System.out.println("4.Hết chỗ");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.trong;
break;
case 2:
status = Status.it;
break;
case 3:
status = Status.vua;
break;
case 4:
status = Status.full;
break;
default:
break;
}
}
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case trong:
System.out.println(">>>Trống");
break;
case it:
System.out.println(">>>Còn ít chỗ");
break;
case vua:
System.out.println(">>> bình thường");
break;
case full:
System.out.println(">>> Hết chỗ");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rapphim;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class quaybandoan implements IStatus{
static enum Status{
Empty,it_khach,vua_phai,rat_dong
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("Trạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Empty;
break;
case 2:
status = Status.it_khach;
break;
case 3:
status = Status.vua_phai;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Empty:
System.out.println(">>>vắng khách");
break;
case it_khach:
System.out.println(">>>khách hàng it");
break;
case vua_phai:
System.out.println(">>>Lượng khách vừa phải");
break;
case rat_dong:
System.out.println(">>>Đang rất đông");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rapphim;
import java.util.Scanner;
/**
*
* @author HOME
*/
class rapphim implements IStatus{
int tong_ghe;
int da_dung_ghe;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Tổng ghế ");
tong_ghe = Integer.parseInt(scan.nextLine());
for(;;){
System.out.println("Số ghế đang dùng : ");
da_dung_ghe = Integer.parseInt(scan.nextLine());
if (da_dung_ghe > tong_ghe) {
System.out.println("Số ghế đang dùng không đc lớn hơn tổng số ghế ");
}else{
break;
}
}
System.out.println("Thời điểm : ");
thoi_diem = scan.nextLine();
}
@Override
public void onStatus() {
System.out.println("Tổng số ghế : "+tong_ghe);
System.out.println("Số ghế đã dùng : "+da_dung_ghe);
System.out.println("Thời điểm : "+thoi_diem);
}
}
![Trần Mạnh Dũng [T1907A]](https://www.gravatar.com/avatar/ee4661d1f9133c241d6c8287c7ea8ceb.jpg?s=80&d=mm&r=g)
Trần Mạnh Dũng
2020-03-16 12:30:58
IStatus
package quan_li_rap_chieu_phim;
public interface IStatus {
public void onStatus();
}
Mainpackage quan_li_rap_chieu_phim;
import java.util.ArrayList;
/**
*
* @author admin
*/
public class main {
public static void main(String[] args) {
ArrayList<IStatus> stsList;
stsList = new ArrayList<>();
inputStatus(stsList);
followStatus(stsList);
}
public static void inputStatus(ArrayList<IStatus> stsList) {
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("Phong ve thu " + s + " :");
TicketCounter tc = new TicketCounter();
tc.input();
stsList.add(tc);
}
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("Phong ve thu " + s + " :");
Food fd = new Food();
fd.input();
stsList.add(fd);
}
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("Phong ve thu " + s + " :");
Parking p1 = new Parking();
p1.input();
stsList.add(p1);
}
for (int i = 0; i < 5; i++) {
Watching wt = new Watching();
wt.input();
stsList.add(wt);
}
}
public static void followStatus(ArrayList<IStatus> statusList) {
for (IStatus iStatus : statusList) {
iStatus.onStatus();
}
}
}
Ticket Counter
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quan_li_rap_chieu_phim;
import java.util.Scanner;
/**
*
* @author admin
*/
public class TicketCounter implements IStatus {
static enum Status {
Trong, KhachHangIt, KhachHangVuaPhai, KhachHangRatDong;
};
Status sts;
String ThoiDiem;
public void input() {
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Nhap thoi diem: ");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. Khach hang it");
System.out.println("3. Khach hang vua phai");
System.out.println("4. Khach hang rat dong");
System.out.print("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
break;
case 2:
sts = Status.KhachHangIt;
break;
case 3:
sts = Status.KhachHangVuaPhai;
break;
case 4:
sts = Status.KhachHangRatDong;
break;
default:
break;
}
}
@Override
public void onStatus(){
System.out.print("\nThời điểm : "+ThoiDiem);
switch(sts){
case Trong:
System.out.println("Trong");
break;
case KhachHangIt:
System.out.println("Khach hang it");
break;
case KhachHangVuaPhai:
System.out.println("Khach hang vua phai");
break;
case KhachHangRatDong:
System.out.println("Dang rat dong");
break;
default:
break;
}
}
}
Watching
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quan_li_rap_chieu_phim;
import java.util.Scanner;
/**
*
* @author admin
*/
public class Watching implements IStatus{
int TatCaGhe;
int GheDangDung;
String ThoiDiem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Tat ca ghe ");
TatCaGhe = Integer.parseInt(scan.nextLine());
for(;;){
System.out.println("So ghe dang su dung : ");
GheDangDung = Integer.parseInt(scan.nextLine());
if (GheDangDung > TatCaGhe) {
System.out.println("So ghe dang dung phai nho hon tong so ghe ");
}else{
break;
}
}
System.out.println("Thoi diem : ");
ThoiDiem = scan.nextLine();
}
@Override
public void onStatus() {
System.out.println("Watching:");
System.out.println("Tat ca ghe: "+TatCaGhe);
System.out.println("So ghe dang su dung: "+GheDangDung);
System.out.println("Thoi diem: "+ThoiDiem);
}
}
Parking
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quan_li_rap_chieu_phim;
import java.util.Scanner;
/**
*
* @author admin
*/
public class Parking implements IStatus{
static enum Status {
Trong, It, VuaPhai, Full;
};
Status sts;
String ThoiDiem;
public void input(){
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Thoi Diem:");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. It");
System.out.println("3. Vua phai");
System.out.println("4. Full");
System.out.println("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
break;
case 2:
sts = Status.It;
break;
case 3:
sts = Status.VuaPhai;
break;
case 4:
sts = Status.Full;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Parking;");
System.out.print("Thoi Diem: "+ThoiDiem);
switch(sts){
case Trong:
System.out.println("Trong");
break;
case It:
System.out.println("Con it cho");
break;
case VuaPhai:
System.out.println("Con vua phai cho");
break;
case Full:
System.out.println("Het cho");
break;
default:
break;
}
}
}
Food
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quan_li_rap_chieu_phim;
import java.util.Scanner;
/**
*
* @author admin
*/
public class Food implements IStatus{
static enum Status {
Trong, KhachHangIt, KhachHangVuaPhai, DangRatDong;
};
Status sts;
String ThoiDiem;
public void input() {
int choose;
Scanner input = new Scanner(System.in);
System.out.println("Thoi Diem:");
ThoiDiem = input.nextLine();
System.out.println("Trang thai : ");
System.out.println("1. Trong");
System.out.println("2. Khach hang it");
System.out.println("3. Khach hang vua phai");
System.out.println("4. Dang rat dong");
System.out.print("Chon: ");
choose = Integer.parseInt(input.nextLine());
switch(choose){
case 1:
sts = Status.Trong;
break;
case 2:
sts = Status.KhachHangIt;
break;
case 3:
sts = Status.KhachHangVuaPhai;
break;
case 4:
sts = Status.DangRatDong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Food:");
System.out.print("Thoi diem : "+ThoiDiem);
switch(sts){
case Trong:
System.out.println("Trong");
break;
case KhachHangIt:
System.out.println("Khach hang it");
break;
case KhachHangVuaPhai:
System.out.println("Khach hang vua phai");
break;
case DangRatDong:
System.out.println("Dang Rat Dong");
break;
default:
break;
}
}
}
![Lê Minh Bắc [T1907A]](https://www.gravatar.com/avatar/22abcac77d8ca5e01144e240abb48d22.jpg?s=80&d=mm&r=g)
Lê Minh Bắc
2020-03-16 12:12:18
TicketCounter:
package QLRapChieuPhim;
import java.util.Scanner;
public class TicketCounter implements IStatus{
String name, address,thoiDiem;
public enum STATUS {
TRONG , IT , VUA_PHAI, RAT_DONG
}
STATUS status;
public void input() {
Scanner input = new Scanner(System.in);
System.out.print("Nhập thời điểm:");
thoiDiem = input.nextLine();
System.out.println("Chọn trạng thái: ");
System.out.println("1. Trống ");
System.out.println("2. Ít ");
System.out.println("3. Vừa phải ");
System.out.println("4. Rất đông ");
System.out.print("Thiết lập: ");
int choose = Integer.parseInt(input.nextLine());
switch (choose) {
case 1:
status = STATUS.TRONG;
break;
case 2:
status = STATUS.IT;
break;
case 3:
status = STATUS.VUA_PHAI;
break;
case 4:
status = STATUS.RAT_DONG;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Thời điểm: " + thoiDiem);
switch (status) {
case TRONG:
System.out.println("Trạng thái: Trống.");
break;
case IT:
System.out.println("Trạng thái: Khách hàng ít.");
break;
case VUA_PHAI:
System.out.println("Trạng thái: Khách hàng vừa phải.");
break;
case RAT_DONG:
System.out.println("Trạng thái: Đang rất đông.");
break;
default:
System.out.println("Trạng thái: Chưa thiết lập.");
break;
}
}
}
Parking:
package QLRapChieuPhim;
import java.util.Scanner;
public class Parking implements IStatus{
String thoiDiem;
public enum STATUS {
TRONG , IT , VUA_PHAI, FULL
}
STATUS status;
public void input() {
Scanner input = new Scanner(System.in);
System.out.print("Nhập thời điểm:");
thoiDiem = input.nextLine();
System.out.println("Chọn trạng thái: ");
System.out.println("1. Trống ");
System.out.println("2. Ít ");
System.out.println("3. Vừa phải ");
System.out.println("4. Full ");
System.out.print("Thiết lập: ");
int choose = Integer.parseInt(input.nextLine());
switch (choose) {
case 1:
status = STATUS.TRONG;
break;
case 2:
status = STATUS.IT;
break;
case 3:
status = STATUS.VUA_PHAI;
break;
case 4:
status = STATUS.FULL;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Thời điểm: " + thoiDiem);
switch (status) {
case TRONG:
System.out.println("Trạng thái: Trống.");
break;
case IT:
System.out.println("Trạng thái: Ít.");
break;
case VUA_PHAI:
System.out.println("Trạng thái: Vừa phải.");
break;
case FULL:
System.out.println("Trạng thái: Full.");
break;
default:
System.out.println("Trạng thái: Chưa thiết lập.");
break;
}
}
}
CinemaRoom:
package QLRapChieuPhim;
import java.util.Scanner;
public class CinemaRoom implements IStatus{
int soGhe, soGheDangDung;
String thoiDiem;
public void input() {
Scanner input = new Scanner(System.in);
System.out.print("Thời điểm: ");
thoiDiem = input.nextLine();
System.out.print("Nhập số ghế: ");
soGhe = Integer.parseInt(input.nextLine());
for(;;){
System.out.print("Nhập số ghế đã dùng: ");
soGheDangDung = Integer.parseInt(input.nextLine());
if(soGheDangDung > soGhe){
System.out.println("Số ghế đang dùng phải < " + soGhe);
}else{
break;
}
}
}
@Override
public void onStatus() {
System.out.println("Thời điểm: " + thoiDiem);
System.out.println("Phòng có " + soGhe + " ghế, số ghế đang sử dụng là: " + soGheDangDung);
}
}
SnackCounter:
package QLRapChieuPhim;
import java.util.Scanner;
public class SnackCounter implements IStatus{
String thoiDiem;
public enum STATUS {
TRONG , IT , VUA_PHAI, FULL
}
STATUS status;
public void input() {
Scanner input = new Scanner(System.in);
System.out.print("Nhập thời điểm:");
thoiDiem = input.nextLine();
System.out.println("Chọn trạng thái: ");
System.out.println("1. Trống ");
System.out.println("2. Ít ");
System.out.println("3. Vừa phải ");
System.out.println("4. Full ");
System.out.print("Thiết lập: ");
int choose = Integer.parseInt(input.nextLine());
switch (choose) {
case 1:
status = STATUS.TRONG;
break;
case 2:
status = STATUS.IT;
break;
case 3:
status = STATUS.VUA_PHAI;
break;
case 4:
status = STATUS.FULL;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Thời điểm: " + thoiDiem);
switch (status) {
case TRONG:
System.out.println("Trạng thái: Trống.");
break;
case IT:
System.out.println("Trạng thái: Ít.");
break;
case VUA_PHAI:
System.out.println("Trạng thái: Vừa phải.");
break;
case FULL:
System.out.println("Trạng thái: Full.");
break;
default:
System.out.println("Trạng thái: Chưa thiết lập.");
break;
}
}
}
IStatus:
package QLRapChieuPhim;
public interface IStatus {
public void onStatus();
}
Main:
package QLRapChieuPhim;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<IStatus> listStatus = new ArrayList<>();
inputStatus(listStatus);
followStatus(listStatus);
}
public static void inputStatus(ArrayList<IStatus> listStatus) {
for (int i = 0; i < 3; i++){
System.out.println("Phòng vé thứ " + (i+1) + ": ");
TicketCounter ticket = new TicketCounter();
ticket.input();
listStatus.add(ticket);
}
for (int i = 0; i < 2; i++) {
System.out.println("Quầy đồ ăn thứ " + (i+1) + ": ");
SnackCounter snack = new SnackCounter();
snack.input();
listStatus.add(snack);
}
for (int i = 0; i < 2; i++) {
System.out.println("Bãi đỗ xe thứ " + (i+1) + ": ");
Parking parking = new Parking();
parking.input();
listStatus.add(parking);
}
for (int i = 0; i < 5; i++) {
System.out.println("Phòng chiếu phim số " + (i+1) + ": ");
CinemaRoom cinema = new CinemaRoom();
cinema.input();
listStatus.add(cinema);
}
}
public static void followStatus(ArrayList<IStatus> listStatus){
for(IStatus iStatus: listStatus){
iStatus.onStatus();
}
}
}
![Trương Công Vinh [T1907A]](https://www.gravatar.com/avatar/223a7e3a46f4a747f81b921fe023fcc4.jpg?s=80&d=mm&r=g)
Trương Công Vinh
2020-03-16 10:45:31
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
/**
*
* @author DELL
*/
public interface IStatus {
public void onStatus();
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class ticket_Counter implements IStatus {
static enum Status {
Trong, It_Khach, binh_thuong, rat_dong;
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("\n\nTrạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
System.out.print("Thiết lập : ");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Trong;
break;
case 2:
status = Status.It_Khach;
break;
case 3:
status = Status.binh_thuong;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Quầy vé >>> \n\n");
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Trong:
System.out.println(">>> Trống");
break;
case It_Khach:
System.out.println(">>> khách hàng it");
break;
case binh_thuong:
System.out.println(">>> Khách hàng vừa phải");
break;
case rat_dong:
System.out.println(">>> Đang rất đông");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class Parking implements IStatus{
static enum Status{
trong , it , vua , full
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("\n\nTrạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.Còn ít chỗ");
System.out.println("3.Bình thường");
System.out.println("4.Hết chỗ");
System.out.println("Thiết lập : ");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.trong;
break;
case 2:
status = Status.it;
break;
case 3:
status = Status.vua;
break;
case 4:
status = Status.full;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Bãi đỗ xe >>>\n\n");
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case trong:
System.out.println(">>> Trống");
break;
case it:
System.out.println(">>> Còn ít chỗ");
break;
case vua:
System.out.println(">>> bình thường");
break;
case full:
System.out.println(">>> Hết chỗ");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class watching implements IStatus {
int tong_ghe;
int da_dung_ghe;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Tổng ghế ");
tong_ghe = Integer.parseInt(scan.nextLine());
for(;;){
System.out.println("Số ghế đang dùng : ");
da_dung_ghe = Integer.parseInt(scan.nextLine());
if (da_dung_ghe > tong_ghe) {
System.out.println("Số ghế đang dùng không đc lớn hơn tổng số ghế ");
}else{
break;
}
}
System.out.println("Thời điểm : ");
thoi_diem = scan.nextLine();
}
@Override
public void onStatus() {
System.out.println("Phòng xem phim >>>\n\n");
System.out.println("Tổng số ghế : "+tong_ghe);
System.out.println("Số ghế đã dùng : "+da_dung_ghe);
System.out.println("Thời điểm : "+thoi_diem);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class do_an implements IStatus{
static enum Status{
Empty,it_khach,vua_phai,rat_dong
};
Status status;
String thoi_diem;
public void input(){
Scanner scan = new Scanner(System.in);
System.out.println("Thơi diem : ");
thoi_diem = scan.nextLine();
System.out.println("\n\nTrạng thái : ");
System.out.println("1.vắng khách");
System.out.println("2.khách hàng it");
System.out.println("3.Lượng khách vừa phải");
System.out.println("4.Đang rất đông");
System.out.print("Thiết lập : ");
int c;
c = Integer.parseInt(scan.nextLine());
switch(c){
case 1:
status = Status.Empty;
break;
case 2:
status = Status.it_khach;
break;
case 3:
status = Status.vua_phai;
break;
case 4:
status = Status.rat_dong;
break;
default:
break;
}
}
@Override
public void onStatus() {
System.out.println("Quầy đồ ăn >>> \n\n");
System.out.print("\nThời điểm : "+thoi_diem);
switch(status){
case Empty:
System.out.println(">>> vắng khách");
break;
case it_khach:
System.out.println(">>> khách hàng it");
break;
case vua_phai:
System.out.println(">>> Lượng khách vừa phải");
break;
case rat_dong:
System.out.println(">>> Đang rất đông");
break;
default:
break;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Test;
import java.util.ArrayList;
/**
*
* @author DELL
*/
public class Test {
public static void main(String[] args) {
ArrayList<IStatus> statusList;
statusList = new ArrayList<>();
inputStatus(statusList);
followStatus(statusList);
}
public static void inputStatus(ArrayList<IStatus> statusList) {
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("phòng vé thứ " + s + " :\n");
ticket_Counter t1 = new ticket_Counter();
t1.input();
statusList.add(t1);
}
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("phòng vé thứ " + s + " :\n");
do_an d1 = new do_an();
d1.input();
statusList.add(d1);
}
for (int i = 0; i < 3; i++) {
int s = i + 1;
System.out.println("phòng vé thứ " + s + " :\n");
Parking p1 = new Parking();
p1.input();
statusList.add(p1);
}
for (int i = 0; i < 5; i++) {
watching w = new watching();
w.input();
statusList.add(w);
}
}
public static void followStatus(ArrayList<IStatus> statusList) {
for (IStatus iStatus : statusList) {
iStatus.onStatus();
}
}
}