๊ด€๋ฆฌ ๋ฉ”๋‰ด

JiYoung Dev ๐Ÿ–ฅ

[JAVA MINI PROJECT] ๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ (2023.04.17~2023.04.23) ๋ณธ๋ฌธ

project

[JAVA MINI PROJECT] ๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ (2023.04.17~2023.04.23)

Shinjio 2023. 4. 23. 13:09

๐ŸŽˆ ํ”„๋กœ์ ํŠธ ์ฃผ์ œ 

java์™€ sql์„ ์ด์šฉํ•˜์—ฌ cmd ์ฝ˜์†”์ฐฝ์—์„œ ํ”Œ๋ ˆ์ด ๊ฐ€๋Šฅํ•œ ๊ฐ„๋‹จํ•œ ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

MVC ํŒจํ„ด์„ ์ค‘์‹ฌ์œผ๋กœ ๊ฒŒ์ž„ ๊ตฌํ˜„
๋‹ค๋งˆ๊ณ ์น˜ ๊ฒŒ์ž„์„ ๊ธฐ๋ณธ์œผ๋กœ ํ•˜์—ฌ ์•„์ด๋””์–ด๋ฅผ ๋„์ถœํ•˜์—ฌ ์ƒˆ๋กœ์šด ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ

 

๐ŸŽˆ ํ”„๋กœ์ ํŠธ ์ผ์ • : 2023.04.17(์›”) ~ 2023.04.22(๊ธˆ)

๋‚ ์งœ ์ง„ํ–‰ ๋‚ด์šฉ
2023.04.17(์›”) ์•„์ด๋””์–ด ํšŒ์˜, ์œ ์Šค์ผ€์ด์Šค ์ž‘์„ฑ
2023.04.18(ํ™”) ์š”๊ตฌ์‚ฌํ•ญ ๋ช…์„ธ์„œ ์ž‘์„ฑ, ํ…Œ์ด๋ธ” ๋ช…์„ธ์„œ ์ž‘์„ฑ
MVC ๋ชจ๋“ˆํ™” ๊ตฌ์„ฑ
ํšŒ์›๊ฐ€์ž… ๋ฐ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
2023.04.19(์ˆ˜) ๊ธฐํƒ€ ๊ฒŒ์ž„ ํ”Œ๋ ˆ์ด ๊ด€๋ จ ๋ชจ๋“  ๊ธฐ๋Šฅ ๊ตฌํ˜„ (java, oracle) 
2023.04.20(๋ชฉ) bgm ์‚ฝ์ž…
์˜ค๋ฅ˜ ์ˆ˜์ • ๋ฐ ๋ณด์™„
๋ฐœํ‘œ์ž๋ฃŒ ์ž‘์„ฑ
2023.04.21(๊ธˆ) ๋ฐœํ‘œ

 

๐ŸŽˆ ๊ฒŒ์ž„ ์†Œ๊ฐœ

 

 

 

 

• ํšŒ์›๊ฐ€์ž… ํ›„ ์ฒซ ๋กœ๊ทธ์ธ์‹œ 3๊ฐœ์˜ ์บ๋ฆญํ„ฐ(ํ’€์Šคํƒ ๊ฐœ๋ฐœ์ž, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ์ž, ์ธ๊ณต์ง€๋Šฅ ๊ฐœ๋ฐœ์ž) ์ค‘ ํ•˜๋‚˜์˜ ์บ๋ฆญํ„ฐ๋ฅผ ์„ ํƒํ•˜์—ฌ ํ‚ค์šฐ๋Š” ๊ฒŒ์ž„

 ์ƒ์„ฑํ•œ ๊ฐœ๋ฐœ์ž ์บ๋ฆญํ„ฐ๋Š” EXP, STRESS, HP 3๊ฐ€์ง€ ์†์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Œ

EXP๋ฅผ ๋†’์ด๋Š” ๋Œ€์‹  STRESS๋Š” ๋†’์•„์ง€๊ณ , HP๋Š” ๋‚ฎ์•„์ง€๋Š” ํ–‰๋™๋“ค๊ณผ HP์™€ STRESS๋ฅผ ๋‚ฎ์ถ”๋Š” ํ–‰๋™๋“ค๋กœ ๊ตฌ์„ฑ

์œ„์˜ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ํ–‰๋™ ์„ ํƒ์„ ํ†ตํ•ด EXP๋ฅผ ๋†’์—ฌ ์—ฌ๋Ÿฌ ์œ ์ € ์ค‘ 1๋“ฑํ•˜๋Š” ๊ฒƒ์ด ๊ฒŒ์ž„์˜ ๋ชฉํ‘œ

 ๋‹จ, STRESS๊ฐ€ 100์„ ๋„˜๊ฑฐ๋‚˜ HP๊ฐ€ 0์ด ๋˜๋ฉด ๊ฒŒ์ž„ ์˜ค๋ฒ„

 STRESS๋‚˜ HP ์ˆ˜์น˜์— ๋”ฐ๋ผ ์ด๋ฒคํŠธ๊ฐ€ ์žˆ์œผ๋‹ˆ ์ฃผ์˜ํ•˜๋ฉฐ ๊ฒŒ์ž„ ์ง„ํ–‰ ํ•„์š”

 

๐ŸŽˆ ์—ญํ•  ๋ถ„๋‹ด

ํŒ€์› ์—ญํ• 
์กฐ์žฅ(๋‚˜) MODEL ๊ตฌ์„ฑ (BGM VO, CHAR VO, USER VO)
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ…Œ์ด๋ธ” ์ƒ์„ฑ
CONTROLLER (BGM์ปจํŠธ๋กค๋Ÿฌ, CHAR DAO, GAME DAO, USER DAO) ์ฝ”๋“œ ์ž‘์„ฑ
MAIN (GAME DAO, CHAR DAO ๊ธฐ๋Šฅ ์—ฐ๊ฒฐ) 
ํŒ€์›1 MAIN ์ž‘์„ฑ (USER DAO ๊ธฐ๋Šฅ ์—ฐ๊ฒฐ, GAME DAO ๊ธฐ๋Šฅ ์—ฐ๊ฒฐ)
PPT ์ œ์ž‘
ํŒ€์›2 MAIN์— ํ•„์š”ํ•œ ๊ตฌ์„ฑ์š”์†Œ (์•„์Šคํ‚ค์ฝ”๋“œ ์ž‘์„ฑ)
BGM ์‚ฝ์ž…
PPT ์ œ์ž‘
ํŒ€์›3 ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ˆ˜์ • 
BGM  ์ปจํŠธ๋กค๋Ÿฌ, BGM VO ์ˆ˜์ •
USER DAO ์ˆ˜์ •

 

๐ŸŽˆ ์ƒ์„ธ ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ ๋‚ด์šฉ

๐Ÿ“– 1์ผ์ฐจ

์›”์š”์ผ ์˜คํ›„ ์ฃผ์ œ๋ฅผ ์„ ์ •ํ•˜๊ณ  ๋‹ค๋งˆ๊ณ ์น˜ ๊ฒŒ์ž„์„ ์–ด๋–ค ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•  ๊ฒƒ์ธ์ง€ ์•„์ด๋””์–ด ํšŒ์˜ ์ง„ํ–‰

๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ ๊ฒŒ์ž„์„ ์ฃผ์ œ๋กœ ๋งŒ๋“ค์ž๋Š” ์˜๊ฒฌ ๋„์ถœํ•˜์˜€๊ณ , ์œ ์Šค์ผ€์ด์Šค ์ž‘์„ฑ์„ ํ†ตํ•ด ์ƒ์„ธ ์•„์ด๋””์–ด ๋„์ถœ

์œ ์Šค์ผ€์ด์Šค๋ฅผ ํ† ๋Œ€๋กœ ์š”๊ตฌ์‚ฌํ•ญ ๋ช…์„ธ์„œ ์ดˆ์•ˆ ์ž‘์„ฑ

 

 

๐Ÿ“– 2์ผ์ฐจ

1์ผ์ฐจ์— ์ž‘์„ฑํ•œ ์œ ์Šค์ผ€์ด์Šค๋ฅผ ํ† ๋Œ€๋กœ ์ƒ์„ธ ์š”๊ตฌ์‚ฌํ•ญ ๋ช…์„ธ์„œ ๋ฐ ํ…Œ์ด๋ธ” ๋ช…์„ธ์„œ ์ž‘์„ฑ

์—ญํ•  ๋ถ„๋‹ด ์ง„ํ–‰ 

- ์—ญํ• ๋ถ„๋‹ด ์ง„ํ–‰์‹œ model + ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค (๋‚˜) / controller (ํŒ€์›3)  / main (ํŒ€์›1) / ์•„์Šคํ‚ค ์ฝ”๋“œ(ํŒ€์›2)๋กœ ๋ถ„๋‹ด ์ง„ํ–‰

- ์œ„์˜ ๊ฒŒ์ž„์€ ์˜๋‹จ์–ด ๋งž์ถ”๊ธฐ, ์•ผ๊ตฌ๊ฒŒ์ž„๋ณด๋‹ค ์žฌ๋ฏธ ์š”์†Œ๊ฐ€ ์ ๊ธฐ ๋•Œ๋ฌธ์— ์•„์Šคํ‚ค ์ฝ”๋“œ ์•„ํŠธ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์‹œ๊ฐ์ ์œผ๋กœ ์žฌ๋ฏธ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•ด ์•„์Šคํ‚ค ์ฝ”๋“œ ํŒŒํŠธ๋ฅผ ๋”ฐ๋กœ ๋ถ„๋‹ดํ•˜์˜€์Œ

 

 

์ž‘์„ฑํ•œ ํ…Œ์ด๋ธ” ๋ช…์„ธ์„œ๋ฅผ ํ† ๋Œ€๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ ํ›„ MODEL ์ฝ”๋“œ ์ž‘์„ฑ

์‹œ๊ฐ„์ด ๋‚จ์•„์„œ ํšŒ์›๊ฐ€์ž… ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„์„ ์œ„ํ•œ CONTOROLEER ์ฝ”๋“œ ์ž‘์„ฑ (DB์—ฐ๊ฒฐ , DB๋‹ซ๊ธฐ, ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž…, ์ „์ฒด ํšŒ์› ์กฐํšŒ ๋ถ€๋ถ„)

 

โš™๏ธ ๋ณ„๋„ ์ง„ํ–‰ ์‚ฌํ•ญ

์œ„์™€ ๊ฐ™์ด ์ฒซ๋‚  ํ˜‘์—…ํ•˜์—ฌ ๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ•ด๋ณธ ๊ฒฐ๊ณผ ํŒ€์›๋งˆ๋‹ค ์ฝ”๋“œ ์ž‘์„ฑ ์†๋„์˜ ์ฐจ์ด๊ฐ€ ์žˆ์Œ์„ ํ™•์ธํ•˜์˜€๊ณ , ๊ตฌ์ฒด์ ์ธ ํ˜‘์—… ๋ฐฉ์•ˆ์ด ํ•„์š”ํ•˜๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ์Œ

๋”ฐ๋ผ์„œ ์„ธ์„ธํ•˜๊ฒŒ ๊ธฐ๋Šฅ์„ ์‚ฌ์ „์— ๋ถ„๋ฅ˜ํ•˜๊ณ  ํŒ€์›์ด ์ œํ•œ ์‹œ๊ฐ„ ๋‚ด์— ์ฝ”๋“œ๋กœ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์„๋งŒํ•œ ๊ธฐ๋Šฅ๋“ค๋กœ ์—ญํ• ์„ ์žฌ๋ถ„๋ฐฐ

์—‘์…€๋กœ ํŒจํ‚ค์ง€์™€ ํด๋ž˜์Šค๋ฅผ ๊ตฌ๋ถ„ํ•˜๊ณ  ๊ทธ ์•ˆ์— ๋“ค์–ด๊ฐ€์•ผ ํ•˜๋Š” ๋ฉ”์„œ๋“œ๋“ค์„  ์ž‘์„ฑํ•œ ํ›„ ์—ญํ•  ์žฌ๋ถ„๋ฐฐ ์ง„ํ–‰

 

์šฐ์„  ํ•˜๋‚˜์˜ ์ž๋ฐ” ํ”„๋กœ์ ํŠธ๋Š” 3๊ฐœ์˜ ํŒจํ‚ค์ง€๋กœ ๋ถ„๋ฅ˜ - Controller, Model, View

Controller : ๊ธฐ๋Šฅ ๊ด€๋ จ 

Model : ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง„ ๊ฐ์ฒด

View : ์‚ฌ์šฉ์ž์™€ ์ƒํ˜ธ์†Œํ†ต

 

๊ฐ๊ฐ์˜ ํŒจํ‚ค์ง€ ๋‚ด์—์„œ ์ฃผ์ œ๋ณ„๋กœ ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฅ˜

1. BGM ๊ด€๋ จ

2. ์œ ์ € ๊ด€๋ จ (ํšŒ์›์ •๋ณด ๋“ฑ)

3. ์บ๋ฆญํ„ฐ ์†์„ฑ ๊ด€๋ จ (exp, hp, stress)

4. ์œ ์ € ์บ๋ฆญํ„ฐ ๊ด€๋ จ (์บ๋ฆญํ„ฐ ์ƒ์„ฑ, ๋žญํ‚น ๋“ฑ)

 

 

์œ„์™€ ๊ฐ™์ด ํด๋ž˜์Šค ๋ถ„๋ฅ˜ ํ›„ ๊ฐ ํด๋ž˜์Šค์—์„œ ํ•„์š”๋กœ ํ•˜๋Š” ๊ธฐ๋Šฅ ์ •์˜

 

 

๐Ÿ“– 3์ผ์ฐจ 

์ƒ์„ธํ•˜๊ฒŒ ์žฌ๋ถ„๋ฐฐ๋œ ๋‚ด์šฉ์„ ํ† ๋Œ€๋กœ ๊ฐ์ž ํ•ด๋‹นํ•˜๋Š” ๋ถ€๋ถ„ ๊ฐœ๋ฐœ ์‹œ์ž‘ 

 

๋‚˜ ๊ฐœ๋ฐœ ๋ถ€๋ถ„

 

์Œ์•… ์‚ฝ์ž…์„ ํ†ตํ•ด ๋ณด๋‹ค ์—ญ๋™์ ์ธ ๊ฒŒ์ž„ ๊ตฌํ˜„์„ ํ•˜๊ณ ์ž bgm ๊ด€๋ จ model, controller ๋ถ€๋ถ„ ์ž‘์„ฑ

→ ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ๊ธฐ๋ณธ ์ฝ”๋“œ ํ† ๋Œ€๋กœ ํŒ€์› 2, ํŒ€์› 3 ๊ฒŒ์ž„์— ๋งž๊ฒŒ ์ฝ”๋“œ ์ˆ˜์ • ๋ฐ main์— ์ ์šฉ 

 

controller ๋ฅผ ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ์‹ค์ œ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” main๋ถ€๋ถ„์ด ๊ฐœ๋ฐœ๋˜์–ด์•ผ ํ–ˆ์Œ

๊ทธ๋Ÿฌ๋‚˜ ์•„์ง ๊ฐœ๋ฐœ์ด ์ง„ํ–‰๋˜์ง€ ์•Š์•„ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ„๋‹จํ•˜๊ฒŒ test main ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉฐ ํ…Œ์ŠคํŠธ ๋ฐ ๊ฐœ๋ฐœ ์ง„ํ–‰

 

package VIEW;

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Scanner;

import Controller.CharDAO;
import Controller.GameDAO;
import Controller.UserDAO;
import MODEL.CharVO;

public class GameMain {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		UserDAO udao = new UserDAO();

		int choice = 0;
		while (true) {

			System.out.println("==== ์Šค์ธ์žฌ ๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ ====");
			System.out.println("๋ฉ”๋‰ด์„ ํƒ [1]ํšŒ์›๊ฐ€์ž… [2]๋กœ๊ทธ์ธ [3]๊ฒŒ์ž„์„ค๋ช… [4]ํšŒ์›ํƒˆํ‡ด [5]๊ฒŒ์ž„์ข…๋ฃŒ >> ");
			choice = sc.nextInt();
			if (choice == 1) {
				System.out.println("=== ํšŒ์›๊ฐ€์ž… ===");
				System.out.println("id์ž…๋ ฅ >> ");
				String inputId = sc.next();
				System.out.println("pw์ž…๋ ฅ >> ");
				String inputPw = sc.next();
				System.out.println("๋‹‰๋„ค์ž„ ์ž…๋ ฅ >> ");
				String inputNick = sc.next();
				udao.join(inputId, inputPw, inputNick);
				System.out.println("ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต!");

			} else if (choice == 2) {
				System.out.println("=== ๋กœ๊ทธ์ธ ===");
				System.out.println("id์ž…๋ ฅ >> ");
				String inputId = sc.next();
				System.out.println("pw์ž…๋ ฅ >> ");
				String inputPw = sc.next();
				udao.login(inputId, inputPw);
				System.out.println("๋กœ๊ทธ์ธ ์„ฑ๊ณต!");
				startGame(udao.login(inputId, inputPw));

			} else if (choice == 3) {
				System.out.println("=== ๊ฒŒ์ž„ ์„ค๋ช… ===");
			} else if (choice == 4) {
				System.out.println("=== ํšŒ์›ํƒˆํ‡ด ===");

			} else if (choice == 5) {
				System.out.println("๊ฒŒ์ž„์ข…๋ฃŒ");
				break;
			} else {
				System.out.println("์˜ฌ๋ฐ”๋ฅธ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.");
			}

		}
	}

	public static void startGame(String nick) {
		GameDAO gdao = new GameDAO();
		Scanner sc = new Scanner(System.in);

		while (true) {
			System.out.println("๋ฉ”๋‰ด ์„ ํƒ >> [1] ์Šค์ธ์žฌ ๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ [2] ๋žญํ‚น ํ™•์ธ [3] ์บ๋ฆญํ„ฐ ์ƒํƒœ ํ™•์ธ [4] ๋‹‰๋„ค์ž„ ๋ณ€๊ฒฝ [5] ์บ๋ฆญํ„ฐ ์‚ญ์ œ [6] ๊ฒŒ์ž„์ข…๋ฃŒ");
			int choice = sc.nextInt();
			if (choice == 1) {
				System.out.println("====== ์Šค์ธ์žฌ ๊ฐœ๋ฐœ์ž ํ‚ค์šฐ๊ธฐ ======");
				
				boolean sw = false;
				
				System.out.println(gdao.userCharList());
				
				if(gdao.userCharList().size()==0) {
					makeChar(nick);
				}

				for (int i = 0; i < gdao.userCharList().size(); i++) {
					if (gdao.userCharList().get(i).getNick().equals(nick)) {
						System.out.println();
						gdao.callChar(nick);

						System.out.println("====== ์บ๋ฆญํ„ฐ ์ƒํƒœ ํ™•์ธ ======");

						int userExp = gdao.charGauge(nick).get(0);
						int userStress = gdao.charGauge(nick).get(1);
						int userHp = gdao.charGauge(nick).get(2);

						System.out.printf("EXP : %d  STRESS : %d  HP : %d\n", userExp, userStress, userHp);
						break;
					}else {
						sw = true;
					}
				}
				
				if(sw) {
					makeChar(nick);
				}
				
				raise(nick);
				
				
				
			} else if (choice == 2) {
				System.out.println("====== ๋žญํ‚น ํ™•์ธ ======");
				for (int i = 0; i < gdao.rank().size(); i++) {
					CharVO temp = gdao.rank().get(i);
					String userNick = temp.getNick();
					int userExp = temp.getExp();
					int userStress = temp.getStress();
					int userHp = temp.getHp();

					System.out.printf("๋‹‰๋„ค์ž„ : %s  EXP : %d  STRESS : %d  HP : %d\n", userNick, userExp, userStress,
							userHp);
				}

			} else if (choice == 3) {
				System.out.println("====== ์บ๋ฆญํ„ฐ ์ƒํƒœ ํ™•์ธ ======");

				int userExp = gdao.charGauge(nick).get(0);
				int userStress = gdao.charGauge(nick).get(1);
				int userHp = gdao.charGauge(nick).get(2);

				System.out.printf("EXP : %d  STRESS : %d  HP : %d\n", userExp, userStress, userHp);

			} else if (choice == 4) {
				System.out.println("====== ๋‹‰๋„ค์ž„ ๋ณ€๊ฒฝ ======");

			} else if (choice == 5) {
				System.out.println("====== ์บ๋ฆญํ„ฐ ์‚ญ์ œ ======");

			} else if (choice == 6) {
				System.out.println("๊ฒŒ์ž„ ์ข…๋ฃŒ");
				break;

			} else {
				System.out.println("์˜ฌ๋ฐ”๋ฅธ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.");
			}
		}

	}

	public static void raise(String nick) {
		CharDAO cdao = new CharDAO();
		GameDAO gdao = new GameDAO();
		Scanner sc = new Scanner(System.in);
		int choice = 0;
		while (true) {
			System.out.println("==== ํ–‰๋™ ์„ ํƒ ====");
			System.out.println("[1]์ถœ๊ทผํ•˜๊ธฐ [2] ์ˆ˜์—…๋“ฃ๊ธฐ [3] ํŒ€ํ”„๋กœ์ ํŠธ ");
			System.out.println("[4]์ฝ”๋”ฉํ…Œ์ŠคํŠธ [5] ์ž๊ฒฉ์ฆ๊ณต๋ถ€ [6] ์˜ˆ์Šต ๋ณต์Šต ");
			System.out.println("[7]์ ์‹ฌ์‹œ๊ฐ„ [8] ์ง‘์—๊ฐ€๊ธฐ [9] ์›”์š”์ผ 5์‹œ ํ‡ด๊ทผ ");
			System.out.println("[10]์ˆ˜์—…์‹œ๊ฐ„์— ์กธ๊ธฐ [11] ์ฃผ๋ง์— ์‰ฌ๊ธฐ [12] ์ปคํ”ผ๋งˆ์‹œ๊ธฐ [0] ๊ทธ๋งŒํ•˜๊ธฐ ");
			choice = sc.nextInt();

			if (choice == 1) {
				cdao.goSmhrd(nick);
			} else if (choice == 0) {
				break;
			} else if (choice == 2) {
				cdao.listeningClass(nick);
			} else if (choice == 3) {
				cdao.teamProject(nick);
			} else if (choice == 4) {
				cdao.codingTest(nick);
			} else if (choice == 5) {
				cdao.studyCertificate(nick);
			} else if (choice == 6) {
				cdao.selfEdu(nick);
			} else if (choice == 7) {
				cdao.lunchTime(nick);
			} else if (choice == 8) {
				cdao.goHome(nick);
			} else if (choice == 9) {
				cdao.monday(nick);
			} else if (choice == 10) {
				cdao.snooze(nick);
			} else if (choice == 11) {
				cdao.weekend(nick);
			} else if (choice == 12) {
				cdao.coffee(nick);
			}

			System.out.println("====== ์บ๋ฆญํ„ฐ ์ƒํƒœ ํ™•์ธ ======");

			int userExp = gdao.charGauge(nick).get(0);
			int userStress = gdao.charGauge(nick).get(1);
			int userHp = gdao.charGauge(nick).get(2);

			System.out.printf("EXP : %d  STRESS : %d  HP : %d\n", userExp, userStress, userHp);
		}

	}

	public static void makeChar(String nick) {
		Scanner sc = new Scanner(System.in);
		GameDAO gdao = new GameDAO();

		System.out.println("๊ฐœ๋ฐœ์ž ์„ ํƒ >> [1]ํ’€์Šคํƒ ๊ฐœ๋ฐœ์ž [2]๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ์ž [3]์ธ๊ณต์ง€๋Šฅ ๊ฐœ๋ฐœ์ž");
		int choice = sc.nextInt();
		gdao.creationChar(nick, choice);

		if (choice == 1) {
			gdao.creationChar(nick, choice);
			System.out.println("ํ’€์Šคํƒ๊ฐœ๋ฐœ์ž ์ƒ์„ฑ ์™„๋ฃŒ!");
		} else if (choice == 2) {
			gdao.creationChar(nick, choice);
			System.out.println("๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ์ž ์ƒ์„ฑ ์™„๋ฃŒ!");
		} else if (choice == 3) {
			gdao.creationChar(nick, choice);
			System.out.println("์ธ๊ณต์ง€๋Šฅ ๊ฐœ๋ฐœ์ž ์ƒ์„ฑ ์™„๋ฃŒ!");
		}

		System.out.println("====== ์บ๋ฆญํ„ฐ ์ƒํƒœ ํ™•์ธ ======");

		int userExp = gdao.charGauge(nick).get(0);
		int userStress = gdao.charGauge(nick).get(1);
		int userHp = gdao.charGauge(nick).get(2);
		System.out.println(nick);
		System.out.printf("EXP : %d  STRESS : %d  HP : %d\n", userExp, userStress, userHp);
	}
}

 

๐Ÿ“– 4์ผ์ฐจ

main ๋ถ€๋ถ„์—์„œ ์ž‘์„ฑํ•ด์•ผํ•˜๋Š” ๋ถ€๋ถ„์ด ๋งŽ์•„ 3์ผ์ฐจ์— ๋‚ด๊ฐ€ ๊ตฌํ˜„ํ•œ ๋ถ€๋ถ„์€ ์ง์ ‘ main ๋ถ€๋ถ„ ์ž‘์„ฑ

๊ธฐ๋Šฅ ํ•˜๋‚˜ ํ•˜๋‚˜์”ฉ ์‹คํ–‰ํ•˜๋ฉด์„œ ์˜ค๋ฅ˜ ํ™•์ธ ๋ฐ ํ•ด๊ฒฐ ์ง„ํ–‰

์‹คํ–‰ํŒŒ์ผ๋กœ ์‹คํ–‰์‹œ ์•„์Šคํ‚ค์ฝ”๋“œ ๋ฐฐ์น˜ ์•ˆ๋งž๋Š” ํ˜„์ƒ์ด ์žˆ์–ด ์ฝ”๋“œ ์ˆ˜์ •ํ•˜์—ฌ ์˜ˆ์˜๊ฒŒ ๋ณด์ด๊ฒŒ ์ˆ˜์ •

๋ฐœํ‘œ์ค€๋น„

 

๋ฐœ์ƒํ–ˆ๋˜ ์˜ค๋ฅ˜ 
1. hp, exp ๊ฐ’์ด ์„œ๋กœ ๋ฐ”๋€Œ์–ด์„œ ์ €์žฅ๋˜๋Š” ํ˜„์ƒ ๋ฐœ์ƒ
์›์ธ ๋ฐ ํ•ด๊ฒฐ๋ฐฉ์•ˆ : model (charVO) ์ž‘์„ฑ์‹œ hp, exp ์ž๋ฆฌ๋ฅผ ๋ฐ”๊ฟ”์„œ ์ž‘์„ฑํ•˜์˜€์Œ. main ํด๋ž˜์Šค์—์„œ charDAO ํด๋ž˜์Šค์˜ ๋ฉ”์„œ๋“œ๋ฅผ ๋Œ์–ด๋‹ค ์“ฐ๊ณ , charDAO๋Š” charVO์˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด ์“ฐ๋ฉด์„œ ์™œ ์ด๋Ÿฐ ํ˜„์ƒ์ด ์ผ์–ด๋‚ฌ๋Š”์ง€ ์ฐพ๊ธฐ ์‰ฝ์ง€ ์•Š์•˜์Œ. ํ•˜๋‚˜ํ•˜๋‚˜ ์ฒœ์ฒœํžˆ ์ฝ”๋“œ๋ฅผ ๋”ฐ๋ผ๊ฐ€๋ฉด์„œ ์˜ค๋ฅ˜ ํ™•์ธ
2. ๊ฒŒ์ž„ ์‹คํ–‰์„ ํ†ตํ•ด ์บ๋ฆญํ„ฐ hp, exp, stress ๋ณ€๋™์‹œ ๋กœ๊ทธ์ธํ•œ ๋‹‰๋„ค์ž„ ์™ธ ๊ธฐ์กด์— ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ €์žฅ๋œ ์บ๋ฆญํ„ฐ ๋ชจ๋‘์˜ hp, exp, stress ํ•จ๊ป˜ ๋ณ€๊ฒฝ 
์›์ธ ๋ฐ ํ•ด๊ฒฐ๋ฐฉ์•ˆ :  ์†์„ฑ ๋ณ€๊ฒฝ ๊ด€๋ จ ๋ฉ”์„œ๋“œ์—์„œ sql ๋ฌธ์žฅ ์ž‘์„ฑ์‹œ where ์กฐ๊ฑด ๋ˆ„๋ฝ → where์ ˆ ์ž‘์„ฑ ํ›„ ์ •์ƒ ์ž‘๋™ 
3. ํšŒ์›ํƒˆํ‡ด ๊ธฐ๋Šฅ ๊ตฌํ˜„์‹œ ์‚ญ์ œ๊ฐ€ ์•ˆ๋˜๋Š” ํ˜„์ƒ ๋ฐœ์ƒ
์›์ธ : ๋‹‰๋„ค์ž„์„ user_info ํ…Œ์ด๋ธ” ์™ธ ๋‹ค๋ฅธ 2๊ฐœ์˜ ํ…Œ์ด๋ธ”์—์„œ ์™ธ๋ž˜ํ‚ค๋กœ ์ฐธ์กฐํ•˜๊ณ  ์žˆ์—ˆ์Œ. ์ด๋กœ์ธํ•ด ์‚ญ์ œ ๋ถˆ๊ฐ€
ํ•ด๊ฒฐ ๋ฐฉ์•ˆ : ํŒ€์›3์—๊ฒŒ ์—ญํ•  ๋ถ„๋ฐฐํ•˜์˜€๊ณ , ํ•ด๊ฒฐ ์™„๋ฃŒ. ๊ธฐ์กด์— ๊ฑธ์–ด๋‘์—ˆ๋˜ ์ œ์•ฝ์กฐ๊ฑด์„ ์‚ญ์ œํ•˜๊ณ  ์ƒˆ๋กญ๊ฒŒ ์ œ์•ฝ์กฐ๊ฑด ์ƒ์„ฑ. ์ œ์•ฝ์กฐ๊ฑด ์ƒ์„ฑ์‹œ cascade on delete ์กฐ๊ฑด์„ ์ฃผ์–ด user_info ํ…Œ์ด๋ธ”์—์„œ ๊ณ„์ •์„ ์‚ญ์ œํ•  ๋•Œ ๋‹ค๋ฅธ ํ…Œ์ด๋ธ”์˜ ์ •๋ณด๋„ ํ•จ๊ป˜ ์‚ญ์ œ๋  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •

 

๐Ÿ“– 5์ผ์ฐจ 

๋ฐœํ‘œ ๋ฐ ์‹œ์—ฐ

 

๐ŸŽˆ ํ”„๋กœ์ ํŠธ ํ›„๊ธฐ

1. ์„ค๊ณ„ ๋‹จ์—์„œ ์ถฉ๋ถ„ํžˆ ๊ณ ๋ฏผํ•œ ํ›„ ๊ฐœ๋ฐœ ํ•„์š” 

 - ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ…Œ์ด๋ธ” ์„ค๊ณ„์‹œ ๋งŽ์€ ๊ณ ๋ฏผ์„ ํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ, ๊ธฐ๋ณธํ‚ค ์„ค์ •์ด๋‚˜ ์ œ์•ฝ์กฐ๊ฑด ์„ค์ • ์ž‘์„ฑ์‹œ ์ข€๋” ์ƒ๊ฐํ–ˆ์œผ๋ฉด ๋น ๋ฅด๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ์—ˆ์„ ๊ฒƒ

 - ๋˜ํ•œ, ํ˜„์žฌ์˜ ํ…Œ์ด๋ธ” ๋Œ€์‹  ์•„๋ž˜์™€ ๊ฐ™์ด ํ…Œ์ด๋ธ”์„ ๊ตฌ์„ฑํ•˜๊ณ , ์ถ”์ƒ/์ƒ์† ๊ฐœ๋…์„ ํ™œ์šฉํ•˜๋ฉด ์บ๋ฆญํ„ฐ๋ณ„๋กœ ๋‹ค๋ฅธ ์†์„ฑ, ๋ฉ”์„ธ์ง€, ํ–‰๋™ ๋“ฑ์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„์ด ๊ฐ€๋Šฅํ–ˆ์„ ๊ฒƒ 

 

2. ํŒ€์›๊ณผ์˜ ํ˜‘์—…์„ ํ†ตํ•ด ์‹œ๊ฐ„ ๋‹จ์ถ• ๋ฐ ํ’๋ถ€ํ•œ ์•„์ด๋””์–ด ํšจ๊ณผ ํ™•์ธ 

 - ํ˜ผ์ž ํ• ๋•Œ๋ณด๋‹ค ํŒ€์›๋“ค๊ณผ ํ•จ๊ป˜ ํ–ˆ์„ ๋•Œ ์‹œ๊ฐ„์ด ํ›จ์”ฌ ๋‹จ์ถ•๋˜์—ˆ๊ณ , ์„œ๋กœ ๋ชจ๋ฅด๋Š” ๋ถ€๋ถ„์„ ๋„์™€๊ฐ€๋ฉฐ ๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์–ด์„œ ์ข‹์•˜์Œ

 - ํŠนํžˆ ์•„์ด๋””์–ด ๋„์ถœ ๋ถ€๋ถ„์—์„œ ๋‚ด๊ฐ€ ์ƒ๊ฐํ•  ์ˆ˜ ์—†์—ˆ๋˜ ๋ถ€๋ถ„๋“ค์„ ๋งŽ์ด ์ƒ๊ฐํ•ด๋‚ด์ฃผ์–ด ์žฌ๋ฏธ์žˆ๋Š” ๊ฒŒ์ž„์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์—ˆ์Œ

 - ๋‹จ, ํ˜‘์—…์‹œ ํŒ€์› ๊ฐœ๊ฐœ๊ธด์˜ ์‹ค๋ ฅ ๋ฐ ์žฅ๋‹จ์ ์„ ์‚ด๋ ค ์—ญํ• ์„ ๋ถ„๋ฐฐํ•˜๋Š”๊ฒŒ ์ค‘์š”ํ•˜๋‹ค๋Š” ์ƒ๊ฐ์„ ํ•˜์˜€์Œ

 

3. main ์ฝ”๋“œ ์ž‘์„ฑ์‹œ ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ๊น”๋”ํ•˜๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์—ˆ์„๊นŒ...? 

 

์ตœ์ข… ์ฝ”๋“œ๋Š” ์•„๋ž˜ ๋งํฌ ์ฐธ์กฐ!

https://github.com/sin6338ki/fullStackCourse/commit/9c7dae0caeb3fbd1306172fcebb2e2438e0f551a

 

์ž๋ฐ” ๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ(2023.04.18~21) · sin6338ki/fullStackCourse@9c7dae0

์ตœ์ข… ์ฝ”๋“œ

github.com