Commit d89200f4 authored by mekind's avatar mekind

recover

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Assignment</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
public class Movie {
private String[] movie;
private boolean[][] vaild;
Movie(){
movie = new String[8];
vaild= new boolean[10][40];
for(int i=0;i<8;i++) for(int j=0;j<40;j++) vaild[i][j]=true;
movie[0]="제목 : 기생충 / 상영 시간 : 0:00-3:00";
movie[1]="제목 : 감기 / 상영 시간 : 3:00-6:00";
movie[2]="제목 : 해리포터 / 상영 시간 : 6:00-9:00";
movie[3]="제목 : 라라랜드 / 상영 시간 : 9:00-12:00";
movie[4]="제목 : 겨울왕국 / 상영 시간 : 12:00-15:00";
movie[5]="제목 : 명탐정 코난 / 상영 시간 : 15:00-18:00";
movie[6]="제목 : 어벤져스 / 상영 시간 : 18:00-21:00";
movie[7]="제목 : 국제시장 / 상영 시간 : 21:00-24:00";
}
public void show_moive() {
System.out.println("*******영화 목록*******");
for(int i=0;i<8;i++) System.out.println(movie[i]);
}
public void show_nummoive() {
System.out.println("*******영화 목록*******");
for(int i=0;i<8;i++) System.out.println((i+1)+". "+movie[i]);
System.out.print("\n\n예매할 영화를 선택해주세요.");
}
public String get_movie(int idx) {
return movie[idx];
}
public void show_vaild(int num) {
System.out.print("*******좌 석*******\n");
for(int i=-1;i<6;i++) {
for(int j=-1;j<6;j++) {
if(i==-1 && j==-1) System.out.print(" ");
else if(i==-1) System.out.print((j+1)+" ");
else if(j==-1) {
char a=(char)(65+i);
System.out.print(a+" ");
}
else if(vaild[num-1][i*6+j]) System.out.print("O ");
else System.out.print("X ");
}
System.out.print("\n");
}
System.out.print("******************\n");
System.out.print("좌석을 선택해주세요 (ex A1) : ");
}
public void set_vaild(int m, char a, char b) {
int loc= (a-'A')*6 + (b-'1');
vaild[m][loc]=false;
}
public boolean get_vaild(int m, char a, char b) {
int loc= (a-'A')*6 + (b-'1');
return vaild[m][loc];
}
}
import java.util.Scanner;
public class Theater {
private Scanner scan;
private int login_check;
private boolean exit_check;
private String cmd;
private User user;
private Movie movie;
public static void main(String[] args) {
Theater program = new Theater();
while(true) {
program.user_program(program.start());
if(program.exit_check) break;
}
System.out.println("영화 예매 프로그램을 종료합니다.");
}
public Theater() {
login_check=-1;
exit_check=false;
scan = new Scanner(System.in);
user = new User();
movie = new Movie();
}
public int start() {
if(login_check != -1) return login_check;
System.out.print("*******영화 예매 프로그램*******\n1. 로그인\n2. 회원가입\n3. 종료\n메뉴를 선택해주세요: ");
cmd = scan.nextLine();
if(cmd.contentEquals("1")) {
String _id, _pw;
System.out.print("*******로그인*******\nID: ");
_id= scan.nextLine();
System.out.print("Password: ");
_pw= scan.nextLine();
login_check=user.login(_id, _pw);
}
else if(cmd.contentEquals("2")) {
String _id, _pw;
System.out.print("*******회원가입*******\nID: ");
_id= scan.nextLine();
System.out.print("Password: ");
_pw= scan.nextLine();
user.set_user(_id, _pw);
}
else if(cmd.contentEquals("3")) {
exit_check=true;
}
else System.out.println("잘못된 입력입니다.");
System.out.println("");
return -1;
}
public void user_program(int idx) {
if(idx==-1) return;
while(true) {
System.out.print("*******유저 프로그램*******\n1. 영화 목록\n2. 예매확인\n3. 종료\n메뉴를 선택해주세요: ");
cmd = scan.nextLine();
if(cmd.contentEquals("1")) {
movie.show_moive();
System.out.print("\n1. 예매\n2. 종료\n메뉴를 선택해주세요 : ");
cmd = scan.nextLine();
if(cmd.contentEquals("1")) {
movie.show_nummoive();
int tmp = scan.nextLine().charAt(0)-'0';
movie.show_vaild(tmp);
String ttmp=scan.nextLine();
if(movie.get_vaild(tmp -1 , ttmp.charAt(0),ttmp.charAt(1))){
user.buy_ticket(idx, movie.get_movie(tmp- 1), ttmp);
movie.set_vaild(tmp -1 , ttmp.charAt(0),ttmp.charAt(1));
}
else System.out.print("이미 예약된 좌석입니다.\n");
}
else System.out.print("유저 프로그램으로 돌아갑니다\n");
}
else if(cmd.contentEquals("2")) {
user.show_ticket(idx);
System.out.print("Press enter to go back to User program\n");
cmd = scan.nextLine();
}
else if(cmd.contentEquals("3")) {
this.login_check=-1;
break;
}
else System.out.println("잘못된 입력입니다.");
System.out.println("");
}
}
}
public class Ticket {
private String[] info;
private int cnt;
public static int total;
public Ticket() {
info=new String[1000];
cnt=0;
total=0;
}
public void set_ticket(String a) {
info[cnt]=a;
total++;
cnt++;
}
public void show() {
for(int i=0;i<cnt;i++) System.out.println(info[i]);
}
public static int get_total() {
return total;
}
}
public class User {
private String[] id;
private String[] pw;
private Ticket[] t;
private int cnt;
public User() {
id= new String[1000];
pw = new String[1000];
t= new Ticket[1000];
for(int i=0;i<1000;i++) t[i]= new Ticket();
cnt=0;
}
public int login(String a, String b) {
for(int i=0;i<cnt;i++) {
if(id[i].contentEquals(a) && pw[i].contentEquals(b)) return i;
}
System.out.println("로그인에 실패하였습니다.");
return -1;
}
public void set_user(String a, String b) {
if(cnt>=1000) {
System.out.println("가입 인원 초과\n");
return;
}
for(int i=0;i<cnt;i++) {
if(id[i].contentEquals(a)) {
System.out.println("이미 존재하는 아이디입니다.\n");
return;
}
}
id[cnt]=a;
pw[cnt]=b;
cnt++;
}
public void buy_ticket(int idx, String mov, String seat) {
String tmp= "Ticket: "+Ticket.get_total()+"/"+mov+"/Seat : "+seat;
t[idx].set_ticket(tmp);
}
public void show_ticket(int idx) {
t[idx].show();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Assignment2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
8
Parasite/0/3
The Flu/3/6
Harry Porter/6/9
La La Land/9/12
Frozen/12/15
Detective Conan/15/18
Avengers/18/21
Ode to My Father/21/24
3
1 admin 1111
0 hyosik 1234
0 minah 4321
public class DuplicatedIdException extends Exception {
public DuplicatedIdException(String a){
super(a+" already exists.");
}
}
public class DuplicatedReservationException extends Exception {
public DuplicatedReservationException(String a) {
super(a+" is already reserved");
}
}
public class InvalidLoginException extends Exception {
public InvalidLoginException(){
super("Login failed.");
}
}
public class InvalidMenuException extends Exception {
public InvalidMenuException(int a) {
super(a+" is an invalid menu number");
}
public InvalidMenuException(String a) {
super("Invalid Access");
}
}
public class Manager extends Member {
public Manager(String _id, String _pw, String st) {
super(_id, _pw, st);
}
}
public class Member {
private String id, pw, status;
private Ticket t;
private int cnt;// ƼÄϼö
public Member(String _id, String _pw, String st) {
id=_id;
pw=_pw;
status=st;
cnt=0;
t= new Ticket();
}
public boolean login(String _id, String _pw) {
if(id.equalsIgnoreCase(_id) && pw.equalsIgnoreCase(_pw)) return true;
return false;
}
public boolean find(String _id) {
if(id.equalsIgnoreCase(_id)) return true;
return false;
}
public String get_status() {
return status;
}
public void buy_ticket(String mov, String seat) {
t.set_ticket(mov, seat, this.id);
cnt++;
}
public void add_ticket(String mov, String seat, String tnum) {
t.add_ticket(mov, seat, this.id, tnum);
cnt++;
}
public int get_cnt() {
return cnt;
}
public void show_ticket() {
t.show();
}
public String output_ticket() {
return t.output_ticket();
}
public boolean matchid(String a) {
if (a.contentEquals(this.id)) return true;
else return false;
}
public String get_output() {
return status+" "+id+" "+pw;
}
}
public class Movie {
private String movie;
private String name, start, end;
private boolean[][] vaild;
private int ccnt;
Movie(String name, String start, String end){
movie="제목 : "+name+"/ 상영시간 : "+start+":00-"+end+":00";
this.name=name;
this.start=start;
this.end=end;
vaild= new boolean[10][40];
for(int i=0;i<6;i++) for(int j=0;j<6;j++) vaild[i][j]=true;
ccnt=0;
}
public String movie_info() {
return movie;
}
public String get_name() {
return name;
}
public String get_output() {
return name+"/"+start+"/"+end;
}
public void show_vaild() {
System.out.print("*******좌 석*******\n");
for(int i=-1;i<6;i++) {
for(int j=-1;j<6;j++) {
if(i==-1 && j==-1) System.out.print(" ");
else if(i==-1) System.out.print((j+1)+" ");
else if(j==-1) {
char a=(char)(65+i);
System.out.print(a+" ");
}
else if(vaild[i][j]) System.out.print("O ");
else System.out.print("X ");
}
System.out.print("\n");
}
System.out.print("******************\n");
System.out.print("좌석을 선택해주세요 (ex A1) : ");
}
public void set_vaild(char a, char b) {
int x= (a-'A');
int y=(b-'1');
ccnt++;
vaild[x][y]=false;
}
public boolean get_vaild(char a, char b) {
int x= (a-'A');
int y=(b-'1');
return vaild[x][y];
}
public boolean exist(char a, char b) {
int x= (a-'A');
int y=(b-'1');
if(x<0 || x>5) return false;
if(y<0 || y>5) return false;
return true;
}
public double rate() {
double cnt=(double)ccnt;
cnt/=36;
return Math.round(cnt*100)/100.0;
}
public int sales() {
return ccnt*10000;
}
public int get_cnt() {
return ccnt;
}
}
public class NotExistSeatException extends Exception {
public NotExistSeatException(String a) {
super(a+" does no exist");
}
}
This diff is collapsed.
public class Ticket {
private String[] info, output;
private int cnt;
private static int total;
public Ticket() {
info=new String[1000];
output=new String[1000];
cnt=0;
total=0;
}
public void set_ticket(String mov, String seat, String id ) {
info[cnt]="Ticket: "+Ticket.get_total()+" / "+mov+" / Seat : "+seat;
output[cnt]=id+"*"+mov+"*"+seat+"*"+total;
total++;
cnt++;
}
public void add_ticket(String mov, String seat, String id , String tnum) {
int tt=Integer.parseInt(tnum);
info[cnt]="Ticket: "+tt+" / "+mov+" / Seat : "+seat;
output[cnt]=id+"*"+mov+"*"+seat+"*"+tt;
total++;
cnt++;
}
public String output_ticket() {
String a="";
for(int i=0;i<cnt;i++) {
a+=output[i];
a+="\n";
}
return a;
}
public void show() {
for(int i=0;i<cnt;i++) System.out.println(info[i]);
}
public static int get_total() {
return total;
}
}
public class User extends Member {
public User(String _id, String _pw, String st) {
super(_id, _pw, st);
}
}
package practice01;
import java.util.Scanner;
public class Lab02 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
String[] s=input.split(",");
String s1=s[0];
String s2=s[1];
s=s1.split(" ");
s2=s2.replace('h', 'H');
s2=s2.replace("ppt", "pdf");
System.out.println("Name Length(Korean) : "+s.length);
for(int a=1;a<s.length; a++) {
String name=s[a];
name=name.substring(0,1).toUpperCase();
System.out.printf(name+".");
}
String name=s[0];
name=name.substring(0,1).toUpperCase()+name.substring(1);
System.out.println(name+" submitted"+s2);
}
}
package practice01;
import java.util.Scanner;
public class Lab02_2 {
public static void main(String[] args) {
Scanner scan= new Scanner(System.in);
String score;
double sum=0;
int cnt=0;
score=scan.nextLine();
score=score.toUpperCase();
String[] ss=score.split(" ");
for(int a=0;a<ss.length;a++) {
cnt++;
int tmp=0;
char s=ss[a].charAt(0);
switch(s) {
case 'A' :
tmp=100;
break;
case 'B' :
tmp=90;
break;
case 'C' :
tmp=80;
break;
case 'D' :
tmp=70;
break;
default:
tmp=0;
break;
}
switch(cnt){
case 1:
System.out.println("1st student's score is "+tmp);
break;
case 2:
System.out.println("2nd student's score is "+tmp);
break;
case 3:
System.out.println("3rd student's score is "+tmp);
break;
default:
System.out.println(cnt+"th student's score is "+tmp);
break;
}
sum+=tmp;
}
String result=String.format("%.2f",sum/cnt);
System.out.println("This class's average = "+result);
}
}
package practice01;
public class Employee {
private String name;
private int age;
private String position;
private int salary;
private int vacationDays;
public Employee(String name, int age) {
this.setter(name,age,"Employee",5000,20);
}
public Employee(String name, int age, String position, int salary) {
this.setter(name, age, position, salary, 20);
}
public Employee(String name, int age, String position, int salary, int vacationDays) {
this.setter(name, age, position, salary, vacationDays);
}
public boolean equals(Employee a) {
if(this.name==a.name && this.position==a.position&&this.age==a.age) {
System.out.println("Equals.");