<Cotroller>
package controller;
import java.util.ArrayList;
import model.Member;
import model.Rank;
import model.Story;
import model.StoryDAO;
import view.Main;
public class Controller {
Main m = new Main();
StoryDAO dao = new StoryDAO();
Story s = null;
Member m2 = null;
public void insert(Member m1) {
int row = dao.insert(m1);
if (row > 0) {
System.out.println("회원가입 완료");
} else {
System.out.println("회원가입 오류(중복)");
}
}
public void selectOne(Member m1) {
Member m3 = dao.selectOne(m1);
if (m3 == null) {
System.out.println("로그인실패");
} else {
System.out.println(m3.getUsername() + "님 환영합니다.");
}
}
public void save(int index, Member m, int gender, int score) {
int row = dao.save(index, m, gender, score);
}
public void inputRank(Member m, int score) {
int row = dao.inputRank(m, score);
}
public ArrayList<Rank> ranking(){
ArrayList<Rank> list = dao.ranking();
for(Rank s : list) {
System.out.println(s.getRank()+"\t"+s.getUsername()+"\t"+s.getScore());
}
return list;
}
}
<DataBase>
package miniProject;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class dataBase {
private Connection conn = null;
private PreparedStatement psmt = null;
private ResultSet rs = null;
public void getConn() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@project-db-stu.ddns.net:1524:xe";
String user = "cgi_1_0418_4";
String password = "smhrd4";
conn = DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void getClose() {
try {
if(rs!=null)
rs.close();
if(psmt!=null)
psmt.close();
if(conn!=null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
System.out.println("자원 반납시 생긴 오류!");
}
}
}
<Member>
package model;
public class Member {
private int m_seq;
private String id = null;
private String pw = null;
private String username = null;
private int gender = 0;
private int save_point = 0;
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public Member(String id, String pw, String username) {
this.id = id;
this.pw = pw;
this.username = username;
}
public Member(String id, String pw) {
this.id = id;
this.pw = pw;
}
public Member(String nick) {
this.username = nick;
}
public void setId(String id) {
this.id = id;
}
public void setPw(String pw) {
this.pw = pw;
}
public void setUsername(String username) {
this.username = username;
}
public int getGender() {
return gender;
}
public void setGender(int gender) {
this.gender = gender;
}
public int getSave_point() {
return save_point;
}
public void setSave_point(int save_point) {
this.save_point = save_point;
}
public Member(int m_seq, String id, String pw, String username) {
this.m_seq = m_seq;
this.id = id;
this.pw = pw;
this.username = username;
}
public Member(int save_point, int gender) {
this.save_point = save_point;
this.gender = gender;
}
public int getm_seq() {
return m_seq;
}
public String getId() {
return id;
}
public String getPassword() {
return pw;
}
public String getPw() {
return pw;
}
public String getUsername() {
return username;
}
}
<Rank>
package model;
public class Rank{
private String username;
private int score;
private int rank;
public Rank(String username, int score, int rank) {
this.username = username;
this.score = score;
this.rank = rank;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getScore() {
return score;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public void setScore(int score) {
this.score = score;
}
}
<Story>
package model;
public class Story {
private int index;
private String story;
private String answer;
private String wrong;
private String woman_Answer;
private String woman_Wrong;
private String man_Answer;
private String man_Wrong;
public String getMan_Answer() {
return man_Answer;
}
public void setMan_Answer(String man_Answer) {
this.man_Answer = man_Answer;
}
public String getMan_Wrong() {
return man_Wrong;
}
public void setMan_Wrong(String man_Wrong) {
this.man_Wrong = man_Wrong;
}
public Story(String answer, String wrong, String woman_Answer, String woman_Wrong) {
this.answer = answer;
this.wrong = wrong;
this.woman_Answer = woman_Answer;
this.woman_Wrong = woman_Wrong;
}
public Story(String story, int index, String answer, String wrong, String woman_Answer, String woman_Wrong) {
this.story = story;
this.index = index;
this.answer = answer;
this.wrong = wrong;
this.woman_Answer = woman_Answer;
this.woman_Wrong = woman_Wrong;
}
// String 하나 매개변수로 사용하는 생성자
// answer story..
public Story(String story, String answer, String wrong) {
this.story = story;
this.answer = answer;
this.wrong = wrong;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public String getWrong() {
return wrong;
}
public void setWrong(String wrong) {
this.wrong = wrong;
}
public String getWoman_Answer() {
return woman_Answer;
}
public void setWoman_Answer(String woman_Answer) {
this.woman_Answer = woman_Answer;
}
public String getWoman_Wrong() {
return woman_Wrong;
}
public void setWoman_Wrong(String woman_Wrong) {
this.woman_Wrong = woman_Wrong;
}
public void setStory(String story) {
this.story = story;
}
public Story(String answer) {
this.answer = answer;
}
public Story(int index) {
this.index = index;
}
public Story(String answer, String wrong) {
this.answer = answer;
this.wrong = wrong;
}
public String getStory() {
return story;
}
}
<StoryDAO>
package model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class StoryDAO {
private Connection conn = null;
private PreparedStatement psmt = null;
private ResultSet rs = null;
Scanner sc = new Scanner(System.in);
public void getConn() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@project-db-stu.ddns.net:1524:xe";
String user = "cgi_1_0418_4";
String password = "smhrd4";
conn = DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) {
//e.printStackTrace();
} catch (SQLException e) {
//e.printStackTrace();
}
}
public void getClose() {
try {
if (rs != null)
rs.close();
if (psmt != null)
psmt.close();
if (conn != null)
conn.close();
} catch (SQLException e) {
//e.printStackTrace();
System.out.println("자원 반납시 생긴 오류!");
}
}
public int insert(Member m1) {
int row = 0;
try {
getConn();
String sql = "insert into member values(m_seq.nextval,?,?,?)";
psmt = conn.prepareStatement(sql);
psmt.setString(1, m1.getId());
psmt.setString(2, m1.getPw());
psmt.setString(3, m1.getUsername());
row = psmt.executeUpdate();
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return row;
}
public Member selectOne(Member m1) {
Member s2 = null;
try {
getConn();
String sql = "select * from member where id=? and password=? ";
psmt = conn.prepareStatement(sql);
psmt.setString(1, m1.getId());
psmt.setString(2, m1.getPw());
rs = psmt.executeQuery();
if (rs.next()) {
String nick = rs.getString("username");
s2 = new Member(nick);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public ArrayList<Rank> ranking() {
ArrayList<Rank> list = new ArrayList<Rank>();
try {
getConn();
String sql = "select id, score ,rank() over (order by score desc) AS R from ranking";
psmt = conn.prepareStatement(sql);
rs = psmt.executeQuery();
while (rs.next()) {
String id = rs.getString("id");
int score = rs.getInt("score");
int rank = rs.getInt("r");
// 하나의 데이터로 묶기!
Rank r = new Rank(id, score, rank);
list.add(r);
}
} catch (SQLException e) {
//e.printStackTrace();
//System.out.println("데이터베이스 연결 실패");
} finally {
getClose();
}
return list;
}
public int save(int index, Member m, int gender, int score) {
// int result = 0;
int row = 0;
String id = m.getId();
try {
getConn();
String sql = "select * from save where id=?";
psmt = conn.prepareStatement(sql);
// 물음표인자는 get.username
psmt.setString(1, id);
rs = psmt.executeQuery();
if (rs.next() == false) {
sql = "insert into save values (?,?,?,?)";
psmt = conn.prepareStatement(sql);
psmt.setString(1, id);
// 5의 자리에 현재 진행중인 스토리 체크!
psmt.setInt(2, index);
psmt.setInt(3, gender);
psmt.setInt(4, score);
row = psmt.executeUpdate();
} else {
sql = "update save set save_point = ?, score = ? where id=?";
psmt = conn.prepareStatement(sql);
// 5의 자리에는 현재 진행중인 스토리 체크!
psmt.setInt(1, index);
psmt.setInt(2, score);
psmt.setString(3, id);
row = psmt.executeUpdate();
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return row;
}
public int inputRank(Member m, int score) {
int row = 0;
String id = m.getId();
try {
getConn();
String sql = "select * from ranking where id=?";
psmt = conn.prepareStatement(sql);
// 물음표인자는 get.username
psmt.setString(1, id);
rs = psmt.executeQuery();
if (rs.next() == false) {
sql = "insert into ranking values (?,?,?)";
psmt = conn.prepareStatement(sql);
psmt.setString(1, id);
// 5의 자리에 현재 진행중인 스토리 체크!
psmt.setInt(2, score);
psmt.setInt(3, 0);
row = psmt.executeUpdate();
} else {
sql = "update ranking set score = ? where id=?";
score += rs.getInt("score");
psmt = conn.prepareStatement(sql);
// 5의 자리에는 현재 진행중인 스토리 체크!
psmt.setInt(1, score);
psmt.setString(2, id);
row = psmt.executeUpdate();
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return row;
}
public int eventGame1() {
Random rd = new Random();
Scanner sc = new Scanner(System.in);
int answer = rd.nextInt(2) + 1;
int result = 0;
System.out.println("=== 이벤트 게임(홀짝 게임) ===");
System.out.print("정답 입력 >> ");
String input = sc.next();
if (answer % 2 == 0) {
if (input == "짝") {
System.out.println("성공입니다.");
result = 1;
} else {
System.out.println("실패입니다.");
result = 0;
}
} else {
if (input == "홀") {
System.out.println("실패입니다.");
result = 0;
} else {
System.out.println("성공입니다.");
result = 1;
}
}
return result;
}
public boolean eventGame2() {
Random rd = new Random();
Scanner sc = new Scanner(System.in);
int answer = rd.nextInt(10) + 1;
boolean result = false;
System.out.println("=== 이벤트 게임(업다운 게임) ===");
int cnt = 0;
while (true) {
if (cnt == 3) {
System.out.println("실패입니다");
break;
}
System.out.println("1~10 사이의 숫자를 입력하세요, 기회는 3번입니다.");
System.out.print("숫자 입력 >> ");
int num = sc.nextInt();
if (answer == num) {
System.out.println("성공입니다.");
result = true;
break;
} else if (answer > num) {
System.out.println("더 큰 수를 입력하세요");
} else {
System.out.println("더 작은 수를 입력하세요");
}
cnt++;
}
return result;
}
public Member callIndex(Member m) {
int save_point = 0;
int gender = 0;
Member m1 = null;
try {
getConn();
String sql = "select save_point, gender from save where id=?";
psmt = conn.prepareStatement(sql);
psmt.setString(1, m.getId());
rs = psmt.executeQuery();
if (rs.next()) {
save_point = rs.getInt("save_point");
gender = rs.getInt("gender");
m1 = new Member(save_point, gender);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return m1;
}
public boolean userCheck(Member m) {
boolean result = false;
try {
getConn();
String sql = "select * from save where id=?";
psmt = conn.prepareStatement(sql);
psmt.setString(1, m.getId());
rs = psmt.executeQuery();
if (rs.next()) {
result = true;
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return result;
}
public Story WomanStory(Story s) {
Story s2 = null;
try {
getConn();
String sql = "select story from woman_story where woman_index = ?";
psmt = conn.prepareStatement(sql);
psmt.setInt(1, s.getIndex());
rs = psmt.executeQuery();
if (rs.next()) {
String story = rs.getString("story");
s2 = new Story(story);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public Story ManStory(Story s) {
Story s2 = null;
try {
getConn();
String sql = "select story from man_story where man_index = ?";
psmt = conn.prepareStatement(sql);
psmt.setInt(1, s.getIndex());
rs = psmt.executeQuery();
if (rs.next()) {
String story = rs.getString("story");
s2 = new Story(story);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public Story ManAnswer(Story s) {
Story s2 = null;
try {
getConn();
String sql = "select * from man_story where man_index = ?";
psmt = conn.prepareStatement(sql);
psmt.setInt(1, s.getIndex());
rs = psmt.executeQuery();
if (rs.next()) {
String answer = rs.getString("answer");
String wrong = rs.getString("wrong");
String man_answer = rs.getString("man_answer");
String man_wrong = rs.getString("man_wrong");
//1. woman_wrong, woman_answer 가져오기
s2 = new Story(answer , wrong, man_answer, man_wrong);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public Story answer(Story s){
Story s2 = null;
try {
getConn();
String sql = "select * from woman_story where woman_index = ?";
psmt = conn.prepareStatement(sql);
psmt.setInt(1, s.getIndex());
rs = psmt.executeQuery();
if (rs.next()) {
String answer = rs.getString("answer");
String wrong = rs.getString("wrong");
String woman_answer = rs.getString("woman_answer");
String woman_wrong = rs.getString("woman_wrong");
//1. woman_wrong, woman_answer 가져오기
s2 = new Story(answer , wrong, woman_answer, woman_wrong);
}
} catch (SQLException e) {
// e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public Story WA(Story s , int num){
Story s2 = null;
try {
getConn();
String sql = "select * from woman_story where woman_index = ?";
psmt = conn.prepareStatement(sql);
psmt.setInt(1, s.getIndex());
rs = psmt.executeQuery();
if (rs.next()) {
String answer = rs.getString("answer");
String wrong = rs.getString("wrong");
s2 = new Story(answer , wrong);
}
} catch (SQLException e) {
//e.printStackTrace();
} finally {
getClose();
}
return s2;
}
public int gender() {
System.out.println("성별을 선택해주세요 [1] 남 : [2] 여");
int select = sc.nextInt();
if(select == 1) {
System.out.println("남성을 선택했습니다.");
}else {
System.out.println("여성을 선택했습니다.");
}
return select;
}
}
<view-Main>
package view;
import java.util.ArrayList;
import java.util.Scanner;
import controller.Controller;
import javazoom.jl.player.MP3Player;
import model.Member;
import model.Story;
import model.StoryDAO;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StoryDAO dao = new StoryDAO();
int score = 0;
int cnt = 20;
int index = 1;
int check = 0;
int input2 = 0;
int gender = 0;
boolean checkc = false;
Controller c = new Controller();
Member m = null;
Story s3 = null;
MP3Player mp3 = new MP3Player();
while (true) {
System.out.println("[1]회원가입 [2]로그인 [3] 게임시작 [4]랭킹조회 [5]종료");
int input = sc.nextInt();
if (input == 1) {
System.out.println("=====회원가입=====");
System.out.print("ID를 입력하세요 : ");
String id = sc.next();
System.out.print("패스워드를 입력하세요 : ");
String pw = sc.next();
System.out.print("사용하실 닉네임을 입력하세요 : ");
String username = sc.next();
m = new Member(id, pw, username);
c.insert(m);
continue;
} else if (input == 2) {
System.out.println("=====로그인=====");
System.out.print("ID : ");
String id = sc.next();
System.out.print("PW : ");
String pw = sc.next();
m = new Member(id, pw);
c.selectOne(m);
continue;
} else if (input == 3) {
checkc = dao.userCheck(m);
if(checkc) {
System.out.println("저장된 게임을 불러오시겠습니까?");
System.out.println("[1] 네 [2] 아니요");
input2 = sc.nextInt();
if(input2 == 1) {
Member m4 = dao.callIndex(m);
index = m4.getSave_point();
gender = m4.getGender();
}else {
gender = dao.gender();
}
}else {
gender = dao.gender();
}
mp3.play("C:\\Users\\smhrd\\Desktop\\Java\\teamProject\\player\\우연히 봄 - 로꼬, 유주 (여자친구) 가사 (Lyrics).mp3");
System.out.println("게임 시작전에 알립니다. 저장을 하고 싶으시면 9번을 입력해주세요!!");
if (gender == 1) {
while (true) {
// 1 . Story를 가지고 오기
Story s = new Story(index);
Story s2 = dao.WomanStory(s);
System.out.println(s2.getAnswer());
s3 = dao.answer(s);
System.out.println(s3.getAnswer() + "\t" + s3.getWrong());
// 2. Stroy에 해당하는 Answer 가지고 오기
if (index != 2 && index != 12) {
System.out.print("[1] or [2] 선택하세요 >> ");
input = sc.nextInt(); // 답을 입력
System.out.println();
}
// 3-1. input == 1 --> woman_answer가 출력
// 3-2. input ==2 --> woman_wrong이 출력
if (input == 1) {
if(index != 2) {
System.out.println(s3.getWoman_Answer());
}
if (index == 1) {
cnt += 5;
}
if (index == 2) {
check = dao.eventGame1();
if (check == 1) {
cnt += 10;
} else {
cnt -= 20;
}
if(check==1) {
System.out.println(s3.getWoman_Answer());
}else {
System.out.println(s3.getWoman_Wrong());
}
}
if (index == 3) {
cnt += 10;
}
if (index == 4) {
cnt -= 10;
}
if (index == 5) {
cnt += 10;
}
if (index == 6) {
cnt += 10;
}
if (index == 7) {
cnt += 10;
}
if (index == 8) {
cnt -= 10;
}
if (index == 9) {
cnt -= 10;
}
if (index == 10) {
cnt += 10;
}
if (index == 11) {
cnt -= 10;
}
if (index == 12) {
checkc = dao.eventGame2();
if(checkc) {
cnt += 20;
}else {
cnt -= 100;
}
break;
}
} else if (input == 9) {
// save
c.save(index, m, gender,cnt);
if(mp3.isPlaying()) {
mp3.stop();
}
System.exit(0);
break;
} else {
if(index != 2) {
System.out.println(s3.getWoman_Wrong());
}
if (index == 1) {
cnt += 10;
}
if (index == 2) {
check = dao.eventGame1();
if (check == 1) {
cnt += 10;
} else {
cnt -= 20;
}
if(check==1) {
System.out.println(s3.getWoman_Answer());
}else {
System.out.println(s3.getWoman_Wrong());
}
}
if (index == 3) {
cnt -= 10;
}
if (index == 4) {
cnt += 10;
}
if (index == 5) {
cnt += 10;
}
if (index == 6) {
cnt -= 10;
}
if (index == 7) {
cnt -= 10;
}
if (index == 8) {
cnt += 10;
}
if (index == 9) {
cnt += 10;
}
if (index == 10) {
cnt -= 10;
}
if (index == 11) {
cnt += 10;
}
if (index == 12) {
checkc = dao.eventGame2();
if(checkc) {
cnt += 20;
}else {
cnt -= 100;
}
break;
}
}
// 총 스코어
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
Thread.sleep(2000);
System.out.println("♡");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(1000);
System.out.println("♥ ♡ ♡ ♡ ♡ ♡ Next Stage ♡ ♡ ♡ ♡ ♥");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(700);
System.out.println("♥ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♥ ");
System.out.println();
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 다음 스토리로 넘어가겠다.
index++;
}
if (cnt >= 80) {
index = 21;
Story s = new Story(index);
Story s2 = dao.WomanStory(s);
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
if(mp3.isPlaying()) {
mp3.stop();
}
mp3.play("C:\\Users\\smhrd\\Desktop\\Java\\teamProject\\player\\Urban Zakapa - Beautiful Day.mp3");
Thread.sleep(2000);
System.out.println(".----------------. .----------------. .----------------. .----------------. \r\n" +
"| .--------------. || .--------------. || .--------------. || .--------------. |\r\n" +
"| | _____ | || | ____ | || | ____ ____ | || | _________ | |\r\n" +
"| | |_ _| | || | .' `. | || ||_ _| |_ _| | || | |_ ___ | | |\r\n" +
"| | | | | || | / .--. \\ | || | \\ \\ / / | || | | |_ \\_| | |\r\n" +
"| | | | _ | || | | | | | | || | \\ \\ / / | || | | _| _ | |\r\n" +
"| | _| |__/ | | || | \\ `--' / | || | \\ ' / | || | _| |___/ | | |\r\n" +
"| | |________| | || | `.____.' | || | \\_/ | || | |_________| | |\r\n" +
"| | | || | | || | | || | | |\r\n" +
"| '--------------' || '--------------' || '--------------' || '--------------' |\r\n" +
" '----------------' '----------------' '----------------' '----------------'");
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(s2.getAnswer());
} else if (cnt < 80) {
index = 22;
Story s = new Story(index);
Story s2 = dao.WomanStory(s);
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
if(mp3.isPlaying()) {
mp3.stop();
}
mp3.play("C:\\Users\\smhrd\\Desktop\\Java\\teamProject\\player\\윤하 - 오늘 헤어졌어요.mp3");
Thread.sleep(2000);
System.out.println(" \r\n" +
".-----.-----.----.----.--.--.\r\n" +
"|__ --| _ | _| _| | |\r\n" +
"|_____|_____|__| |__| |___ |\r\n" +
" |_____|");
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(s2.getAnswer());
}
try {
c.inputRank(m, cnt);
System.out.println();
Thread.sleep(1000);
System.out.println("10초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("9초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("8초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("7초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("6초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("5초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("4초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("3초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("2초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("1초후에 종료됩니다.");
} catch (InterruptedException e) {
e.printStackTrace();
}
if(mp3.isPlaying()) {
mp3.stop();
}
System.exit(0);
} else if (gender == 2) {
while (true) {
// 1 . Story를 가지고 오기
Story s = new Story(index);
Story s2 = dao.ManStory(s);
System.out.println(s2.getAnswer());
// 2. Stroy에 해당하는 Answer 가지고 오기
s3 = dao.ManAnswer(s);
System.out.println(s3.getAnswer() + "\t" + s3.getWrong());
if (index != 2 && index != 12) {
System.out.print("[1] or [2] 선택하세요 >> ");
input = sc.nextInt(); // 답을 입력
System.out.println();
}
// 3-1. input == 1 --> woman_answer가 출력
// 3-2. input ==2 --> woman_wrong이 출력
if (input == 1) {
if(index!=2) {
System.out.println(s3.getWoman_Answer());
}
if (index == 1) {
cnt += 10;
}
if (index == 2) {
check = dao.eventGame1();
if (check == 1) {
cnt += 10;
} else {
cnt -= 20;
}
if(check==1) {
System.out.println(s3.getWoman_Answer());
}else {
System.out.println(s3.getWoman_Wrong());
}
}
if (index == 3) {
cnt += 10;
}
if (index == 4) {
cnt -= 10;
}
if (index == 5) {
cnt += 10;
}
if (index == 6) {
cnt += 10;
}
if (index == 7) {
cnt += 10;
}
if (index == 8) {
cnt += 10;
}
if (index == 9) {
cnt -= 10;
}
if (index == 10) {
cnt += 10;
}
if (index == 11) {
cnt -= 10;
}
if (index == 12) {
checkc = dao.eventGame2();
if(checkc) {
cnt += 20;
}else {
cnt -= 100;
}
break;
}
} else if (input == 9) {
c.save(index, m,gender,cnt);
if(mp3.isPlaying()) {
mp3.stop();
}
System.exit(0);
} else {
if(index!=2) {
System.out.println(s3.getWoman_Wrong());
}
if (index == 1) {
cnt -= 10;
}
if (index == 2) {
check = dao.eventGame1();
if (check == 1) {
cnt += 5;
} else {
cnt -= 20;
}
if(check==1) {
System.out.println(s3.getWoman_Answer());
}else {
System.out.println(s3.getWoman_Wrong());
}
}
if (index == 3) {
cnt -= 10;
}
if (index == 4) {
cnt += 10;
}
if (index == 5) {
cnt -= 10;
}
if (index == 6) {
cnt -= 10;
}
if (index == 7) {
cnt -= 10;
}
if (index == 8) {
cnt -= 10;
}
if (index == 9) {
cnt += 10;
}
if (index == 10) {
cnt -= 10;
}
if (index == 11) {
cnt += 10;
}
if (index == 12) {
checkc = dao.eventGame2();
if(checkc) {
cnt += 20;
}else {
cnt -= 100;
}
break;
}
}
// 총 스코어
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
Thread.sleep(2000);
System.out.println("♡");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(1000);
System.out.println("♥ ♡ ♡ ♡ ♡ ♡ Next Stage ♡ ♡ ♡ ♡ ♥");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(300);
System.out.println("♡");
Thread.sleep(700);
System.out.println("♥ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♥ ");
System.out.println();
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 다음 스토리로 넘어가겠다.
index++;
}
if (cnt >= 80) {
index = 21;
Story s = new Story(index);
Story s2 = dao.ManStory(s);
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
if(mp3.isPlaying()) {
mp3.stop();
}
mp3.play("C:\\Users\\smhrd\\Desktop\\Java\\teamProject\\player\\Urban Zakapa - Beautiful Day.mp3");
Thread.sleep(2000);
System.out.println(".----------------. .----------------. .----------------. .----------------. \r\n" +
"| .--------------. || .--------------. || .--------------. || .--------------. |\r\n" +
"| | _____ | || | ____ | || | ____ ____ | || | _________ | |\r\n" +
"| | |_ _| | || | .' `. | || ||_ _| |_ _| | || | |_ ___ | | |\r\n" +
"| | | | | || | / .--. \\ | || | \\ \\ / / | || | | |_ \\_| | |\r\n" +
"| | | | _ | || | | | | | | || | \\ \\ / / | || | | _| _ | |\r\n" +
"| | _| |__/ | | || | \\ `--' / | || | \\ ' / | || | _| |___/ | | |\r\n" +
"| | |________| | || | `.____.' | || | \\_/ | || | |_________| | |\r\n" +
"| | | || | | || | | || | | |\r\n" +
"| '--------------' || '--------------' || '--------------' || '--------------' |\r\n" +
" '----------------' '----------------' '----------------' '----------------'");
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(s2.getAnswer());
} else if (cnt < 80) {
index = 22;
Story s = new Story(index);
Story s2 = dao.ManStory(s);
try {
System.out.println(" ♡ 현재 당신에게 호감도는 ♡ " + cnt + "점입니다");
if(mp3.isPlaying()) {
mp3.stop();
}
mp3.play("C:\\Users\\smhrd\\Desktop\\Java\\teamProject\\player\\윤하 - 오늘 헤어졌어요.mp3");
Thread.sleep(2000);
System.out.println(" \r\n" +
".-----.-----.----.----.--.--.\r\n" +
"|__ --| _ | _| _| | |\r\n" +
"|_____|_____|__| |__| |___ |\r\n" +
" |_____|");
System.out.println();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(s2.getAnswer());
}
try {
c.inputRank(m, cnt);
System.out.println();
Thread.sleep(1000);
System.out.println("10초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("9초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("8초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("7초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("6초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("5초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("4초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("3초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("2초후에 종료됩니다.");
Thread.sleep(1000);
System.out.println("1초후에 종료됩니다.");
} catch (InterruptedException e) {
e.printStackTrace();
}
if(mp3.isPlaying()) {
mp3.stop();
}
System.exit(0);
}
} else if (input == 4) {
c.ranking();
continue;
} else if (input == 5) {
System.exit(0);
} else {
break;
}
}
}
}
'1차 프로젝트' 카테고리의 다른 글
1차프로젝트_ppt, 소감 (0) | 2022.07.22 |
---|---|
1차 프로젝트_ 연애시뮬레이션 시연 (0) | 2022.07.22 |
1차프로젝트_유스케이스 (0) | 2022.07.22 |