νμ κ³Όλͺ©κ³Ό μ ν κ³Όλͺ©μ΄ μ‘΄μ¬ν©λλ€.
νμ κ³Όλͺ©
- Java
- κ°μ²΄μ§ν₯
- Spring
- JPA
- MySQL
μ ν κ³Όλͺ©
λμμΈ ν¨ν΄
- Spring Security
- Redis
- MongoDB
μΊ ν μκ°μλ€μ μ΅μ 3κ° μ΄μμ νμ κ³Όλͺ©κ³Ό 2κ° μ΄μμ μ ν κ³Όλͺ©μ μ νν©λλ€.
μΊ ν μκ°μλ€μ μΊ ν κΈ°κ°λμ μ νν κ³Όλͺ©λ³λ‘ μ΄ 10νμ μνμ λ΄ λλ€.
μ μμ λ°λΌ λ±κΈμ΄ 맀겨μ§λλ€.e.g. Java
1νμ°¨ 2νμ°¨ 3νμ°¨ D D B λ±κΈ μ°μ κΈ°μ€
- νμκ³Όλͺ©
A B C D F N 95 ~ 100 90 ~ 94 80 ~ 89 70 ~ 79 60 ~ 69 60μ λ―Έλ§
- μ νκ³Όλͺ©
A B C D F N 90 ~ 100 80 ~ 89 70 ~ 79 60 ~ 69 50 ~ 59 50μ λ―Έλ§
- μΊ ν 맀λμ λ μκ°μμ λ±λ‘ λ° κ΄λ¦¬ν μ μμ΅λλ€.
- μκ°μ μ 보 μμ
- κ³ μ λ²νΈ
- μ΄λ¦
- κ³Όλͺ© λͺ©λ‘
- μ μ λͺ©λ‘
- μΊ ν 맀λμ λ μκ°μλ€μ κ³Όλͺ©κ³Ό μν μ μλ₯Ό λ±λ‘ λ° κ΄λ¦¬ν μ μμ΅λλ€.
- κ³Όλͺ© μ 보 μμ
- κ³ μ λ²νΈ
- κ³Όλͺ©λͺ
- κ³Όλͺ©νμ (νμ, μ ν)
- μ μ μ 보 μμ
- κ³Όλͺ© κ³ μ λ²νΈ
- μκ°μ κ³ μ λ²νΈ
- νμ°¨
- μ μ
- λ±κΈ
- κΈ°λ₯ λͺ μΈμ
- νμ μꡬ μ¬ν
- μκ°μ κ΄λ¦¬
- μκ°μ μ 보λ₯Ό λ±λ‘ν μ μμ΅λλ€.
- λ±λ‘ νμ μ 보
- κ³ μ λ²νΈ
- μ΄λ¦
- κ³Όλͺ© λͺ©λ‘
- μ£Όμ!
- μκ°μμ κ³ μ λ²νΈλ μ€λ³΅λ μ μμ΅λλ€!
- μ νν νμ κ³Όλͺ©μ΄ 3κ° λ―Έλ§μΌ μ μμ΅λλ€!
- μ νν μ ν κ³Όλͺ©μ΄ 2κ° λ―Έλ§μΌ μ μμ΅λλ€!
- μκ°μ λͺ©λ‘μ μ‘°νν μ μμ΅λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- κ³ μ λ²νΈ
- μ΄λ¦
- μ μ κ΄λ¦¬
- μκ°μμ κ³Όλͺ©λ³ μν νμ°¨ λ° μ μλ₯Ό λ±λ‘ν μ μμ΅λλ€.
- μ μλ₯Ό λ±λ‘νλ©΄ μλμΌλ‘ λ±κΈμ΄ μΆκ° μ μ₯λ©λλ€.
- μ£Όμ!
- λ±λ‘νλ €λ κ³Όλͺ©μ νμ°¨ μ μκ° μ΄λ―Έ λ±λ‘λμ΄ μλ€λ©΄ λ±λ‘ν μ μμ΅λλ€. (κ³Όλͺ©μ νμ°¨ μ μκ° μ€λ³΅λμ΄ λ±λ‘λ μ μμ΅λλ€!)
- νμ°¨μ 10 μ΄κ³Ό λ° 1 λ―Έλ§μ μκ° μ μ₯λ μ μμ΅λλ€. (νμ°¨λ 1 ~ 10)
- μ μμ 100 μ΄κ³Ό λ° μμκ° μ μ₯λ μ μμ΅λλ€. (μ μλ 0 ~ 100)
- μκ°μμ κ³Όλͺ©λ³ νμ°¨ μ μλ₯Ό μμ ν μ μμ΅λλ€.
- μκ°μμ νΉμ κ³Όλͺ© νμ°¨λ³ λ±κΈμ μ‘°νν μ μμ΅λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- νμ°¨
- λ±κΈ
- μκ°μ κ΄λ¦¬
1. μκ°μ μνλ₯Ό κ΄λ¦¬ν μ μμ΅λλ€.
- μν μ’ λ₯
- Green
- Red
- Yellow
2. μκ°μ μ 보λ₯Ό μ‘°νν μ μμ΅λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- κ³ μ λ²νΈ
- μ΄λ¦
- μν
- μ νν κ³Όλͺ©λͺ
3. μκ°μ μ 보λ₯Ό μμ ν μ μμ΅λλ€.
- μμ κ°λ₯ν μ 보
- μ΄λ¦
- μν
- μ΄λ¦ λλ μνλ₯Ό μ λ ₯λ°μ μμ νμλ©΄ λ©λλ€.
4. μνλ³ μκ°μ λͺ©λ‘μ μ‘°νν μ μμ΅λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- κ³ μ λ²νΈ
- μ΄λ¦
5. μκ°μμ μμ ν μ μμ΅λλ€.
- ν΄λΉ μκ°μμ μ μ κΈ°λ‘λ ν¨κ» μμ λ©λλ€.
- μ μ κ΄λ¦¬
1. μκ°μμ κ³Όλͺ©λ³ νκ· λ±κΈμ μ‘°νν μ μμ΅λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- κ³Όλͺ©λͺ
- νκ· λ±κΈ
2. νΉμ μν μκ°μλ€μ νμ κ³Όλͺ© νκ· λ±κΈμ μ‘°νν©λλ€.
- μ‘°ν νμμ μμ μ λλ€.
- μ‘°ν νμ μ 보
- μκ°μ μ΄λ¦
- νμ κ³Όλͺ© νκ· λ±κΈ
Main : Management ν΄λμ€λ₯Ό μ€νμν€λ λ©μΈν΄λμ€
Management : μ¬μ©μμ μ λ ₯μ λ°λΌ Databaseν΄λμ€μ ν¨μλ₯Ό νμ©νμ¬ μΆλ ₯νλ μ± ν΄λμ€
DataBase : νμκ΄λ¦¬μ νμν κΈ°λ₯μ μ²λ¦¬νλ ν΄λμ€
Student : νμμ μ΄λ¦, κ³ μ λ²νΈ, μνλ₯Ό λ΄κ³ μλ ν΄λμ€
Subject : κ³Όλͺ©μ μ΄λ¦, νμμ¬λΆλ₯Ό λ΄κ³ μλ ν΄λμ€
SubjectScore : κ³Όλͺ©μ νμ°¨, μ μ, λ±κΈμ λ΄κ³ μλ ν΄λμ€
ScreenData : νλ©΄ μΆλ ₯μμ λ°λ³΅λλ λΆλΆμ λ΄κ³ μλ ν΄λμ€ μΆλ ₯λ¬Έμ κ°μν ν΄μ€
ScreenStage : νλ©΄ μΆλ ₯λΆμ μ΄λ¦μ μ μνλ enumeration ν΄λμ€
- managementλ₯Ό μ μΈνκ³ , μ± ν΄λμ€λ₯Ό νΈμΆ
import Service.Management;
public class Main {
public static void main(String[] args) {
Management management = new Management();
management.run();
}
}
- dataBase, screenDataλ₯Ό μ μΈνκ³ , λ©λ΄ν¨μλ€μ ν΅ν΄ μ¬μ©μμ μ λ ₯μ λ°λΌ μλ
- screenDataλ₯Ό μ¬μ©νμ¬ μ¬λ¬μ€ λ°λ³΅νμ¬ μ¬μ©λλ printfλ¬Έμ νμ€μ μ½λλ‘ λ³κ²½
package Service;
import Data.DataBase;
import Screen.ScreenStage;
import Screen.ScreenData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Management{
private Scanner sc = new Scanner(System.in);
private DataBase dataBase = new DataBase();
private ScreenData screenData = new ScreenData();
public void run() {
mainMenu();
}
private void mainMenu() {
boolean flag = true;
while (flag) {
System.out.println(screenData.getStringData(ScreenStage.MAIN_MENU));
String input = sc.nextLine();
switch (inputSelect(input)) {
case 1 -> studentMenu(); // μκ°μ κ΄λ¦¬
case 2 -> scoreMenu(); // μ μ κ΄λ¦¬
case 3 -> flag = false; // νλ‘κ·Έλ¨ μ’
λ£
default -> {
System.out.println("μλͺ»λ μ
λ ₯μ
λλ€.\nλλμκ°λλ€!");
}
}
}
}
private void studentMenu() {
boolean flag = true;
while (flag) {
System.out.println(screenData.getStringData(ScreenStage.STUDENT_MAIN_MENU));
String input = sc.nextLine();
switch (inputSelect(input)) {
case 1 -> registerStudentMenu(); // μκ°μ λ±λ‘
case 2 -> inquireStudentMenu(); // μκ°μ μ‘°ν
case 3 -> changeStudentMenu(); // μκ°μ μμ
case 4 -> deleteStudentMenu(); // μκ°μ μμ
case 5 -> flag = false; // νλ‘κ·Έλ¨ μ’
λ£
default -> {
System.out.println("μλͺ»λ μ
λ ₯μ
λλ€.\nλλμκ°λλ€!");
}
}
}
}
private void scoreMenu() {
boolean flag = true;
while (flag) {
System.out.println(screenData.getStringData(ScreenStage.SCORE_MAIN_MENU));
String input = sc.nextLine();
switch (inputSelect(input)) {
case 1 -> registerScoreMenu(); // μ μ λ±λ‘
case 2 -> inquireScoreMenu(); // μ μ μ‘°ν
case 3 -> changeScoreMenu(); // μ μ μ
case 4 -> flag = false;
default -> {
System.out.println("μλͺ»λ μ
λ ₯μ
λλ€.\nλλμκ°λλ€!");
}
}
}
}
private void registerStudentMenu() {
String studentSubject;
List<String> studentsubjectList = new ArrayList<>();
System.out.println(screenData.getStringData(ScreenStage.STUDENT_REGISTER_MENU));
System.out.println("μκ°μμ μ΄λ¦μ μ
λ ₯ν΄μ£ΌμΈμ.");
String studentName = sc.nextLine();
System.out.println("μκ°μμ μνλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ.");
String studentStatus = sc.nextLine();
do {
System.out.println("μκ°μμ νμκ³Όλͺ© λͺ©λ‘μ μ
λ ₯ν΄μ£ΌμΈμ. [Java κ°μ²΄μ§ν₯ Spring JPA MySQL]");
studentSubject = sc.nextLine();
}while(studentSubject.split(" ").length<2);
studentsubjectList.addAll(Arrays.asList(studentSubject.split(" ")));
do {
System.out.println("μκ°μμ μ νκ³Όλͺ© λͺ©λ‘μ μ
λ ₯ν΄μ£ΌμΈμ. [λμμΈ_ν¨ν΄ Spring_Security Redis MongoDB]");
studentSubject = sc.nextLine();
}while(studentSubject.split(" ").length<1);
studentsubjectList.addAll(Arrays.asList(studentSubject.split(" ")));
System.out.printf("μ΄λ¦ : %-5s | κ³Όλͺ© : %-40s | μν : %-5s\n", studentName, String.join(", ",studentsubjectList),studentStatus);
System.out.println("μκ°μμ λ±λ‘ νμκ² μ΅λκΉ?");
System.out.println("1. λ€");
System.out.println("2. μλμ€");
String input = sc.nextLine();
if(inputSelect(input)==1)
dataBase.createStudent(studentName, studentStatus, studentsubjectList);
}
private void inquireStudentMenu() {
boolean flag = true;
while (flag) {
System.out.println(screenData.getStringData(ScreenStage.STUDENT_INQUIRE_MENU));
System.out.println("1. κ³ μ λ²νΈλ‘ μ‘°ννκΈ°");
System.out.println("2. μνλ‘ μ‘°ννκΈ°");
String input = sc.nextLine();
switch (inputSelect(input)) {
case 1 -> {
System.out.println("μ‘°νν μκ°μμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
input = sc.nextLine();
dataBase.printStudentById(input);
}
case 2 -> {
System.out.println("μ‘°νν μκ°μμ μνλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
input = sc.nextLine();
dataBase.printStudentByStatus(input);
}
case 3 -> flag = false; // νλ‘κ·Έλ¨ μ’
λ£
default -> {
System.out.println("μλͺ»λ μ
λ ₯μ
λλ€.\nλλμκ°λλ€!");
}
}
}
}
private void changeStudentMenu() {
System.out.println(screenData.getStringData(ScreenStage.STUDENT_DELETE_MENU));
System.out.println("μμ ν μκ°μμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String id = sc.nextLine();
dataBase.printStudentById(id);
System.out.println("μκ°μμ μλ‘μ΄ μ΄λ¦μ μ
λ ₯ν΄μ£ΌμΈμ");
String name = sc.nextLine();
System.out.println("μκ°μμ μλ‘μ΄ μνλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String status = sc.nextLine();
System.out.println("μκ°μ μ 보λ₯Ό λ³κ²½ νμκ² μ΅λκΉ?");
System.out.println("1. λ€");
System.out.println("2. μλμ€");
String input = sc.nextLine();
if(inputSelect(input)==1)
dataBase.changeStudent(id,name,status);
}
private void deleteStudentMenu() {
System.out.println(screenData.getStringData(ScreenStage.STUDENT_DELETE_MENU));
System.out.println("μμ ν μκ°μμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String id = sc.nextLine();
dataBase.printStudentById(id);
System.out.println("μκ°μμ μμ νμκ² μ΅λκΉ?");
System.out.println("1. λ€");
System.out.println("2. μλμ€");
String input = sc.nextLine();
if(inputSelect(input)==1)
dataBase.deleteStudent(id);
}
private void registerScoreMenu() {
System.out.println(screenData.getStringData(ScreenStage.SCORE_REGISTER_MENU));
System.out.println("μ μλ₯Ό μ
λ ₯ν νμμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String id = sc.nextLine();
System.out.println("μ μλ₯Ό μ
λ ₯ν κ³Όλͺ©μ μ
λ ₯ν΄μ£ΌμΈμ");
String subject = sc.nextLine();
String key = id + subject;
System.out.printf("%d νμ°¨ μ μλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ.", dataBase.getRound(key));
String score = sc.nextLine();
System.out.printf("%d νμ°¨ μ μ : %sμ \n", dataBase.getRound(key), score);
System.out.println("μ μλ₯Ό λ±λ‘ νμκ² μ΅λκΉ?");
System.out.println("1. λ€");
System.out.println("2. μλμ€");
String input = sc.nextLine();
if(inputSelect(input)==1)
dataBase.registerScore(id, subject, inputSelect(score));
}
private void inquireScoreMenu() {
boolean flag = true;
while (flag) {
System.out.println(screenData.getStringData(ScreenStage.SCORE_INQUIRE_MENU));
System.out.println("1. κ³ μ λ²νΈλ‘ μ‘°ννκΈ°");
System.out.println("2. μνλ‘ μ‘°ννκΈ°");
String input = sc.nextLine();
switch (inputSelect(input)) {
case 1 -> {
System.out.println("μ‘°νν μκ°μμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
input = sc.nextLine();
dataBase.printScoreById(input);
}
case 2 -> {
System.out.println("μ‘°νν μκ°μμ μνλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
input = sc.nextLine();
dataBase.printScoreByStatus(input);
}
case 3 -> flag = false; // νλ‘κ·Έλ¨ μ’
λ£
default -> {
System.out.println("μλͺ»λ μ
λ ₯μ
λλ€.\nλλμκ°λλ€!");
}
}
}
}
private void changeScoreMenu() {
System.out.println(screenData.getStringData(ScreenStage.SCORE_CHANGE_MENU));
System.out.println("μ μλ₯Ό μμ ν μκ°μμ κ³ μ λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String id = sc.nextLine();
dataBase.printStudentById(id);
System.out.println("μ μλ₯Ό μμ ν κ³Όλͺ©μ μ
λ ₯ν΄μ£ΌμΈμ");
String subject = sc.nextLine();
System.out.println("μ μλ₯Ό μμ ν νμ°¨λ₯Ό μ
λ ₯ν΄μ£ΌμΈμ");
String round = sc.nextLine();
System.out.printf("%d νμ°¨μ μλ‘μ΄ μ μλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ\n",inputSelect(round));
String score = sc.nextLine();
System.out.println("μ μλ₯Ό λ³κ²½ νμκ² μ΅λκΉ?");
System.out.println("1. λ€");
System.out.println("2. μλμ€");
String input = sc.nextLine();
if(inputSelect(input)==1)
dataBase.changeScore(id,subject, inputSelect(round), inputSelect(score));
}
private boolean isDigit(String number){
char[] chars = number.toCharArray();
for (char ch : chars) {
if (ch < '0' || ch > '9') return false;
}
return true;
}
private int inputSelect(String number){
if(isDigit(number))
return Integer.parseInt(number);
else
return 0;
}
}
- Management ν΄λμ€μμ μ¬μ©μκ° μ λ ₯λ°μ κ°μ μ²λ¦¬
- νμκ³Ό κ³Όλͺ©μ λν μ 보λ₯Ό keyκ°μΌλ‘ μ‘°νν μ μλλ‘ μ 보λ₯Ό Map μΌλ‘ ꡬν
package Data;
import Resource.Student;
import Resource.Subject;
import Resource.SubjectScore;
import java.util.*;
public class DataBase {
private final List<Student> studentList = new ArrayList<>();
private final Set<Subject> subjectList = new HashSet<>();
// key : studentId + subjectName value : κ³Όλͺ©μ΄λ¦
private final Set<String> subjectSet = new HashSet<>();
// key : studentId + subjectName value : ν΄λΉidμ νμμ ν΄λΉ κ³Όλͺ©μ νμ°¨λ³ μ μ λͺ©λ‘
private final Map<String, List<SubjectScore>> subjectScoreMap = new HashMap<>();
// key : μν value : νμ리μ€νΈ
private final Map<String, List<Student>> studentStatusMap = new HashMap<>();
public DataBase() {
databaseInit();
}
private void databaseInit() {
subjectList.add(new Subject("Java", true));
subjectList.add(new Subject("κ°μ²΄μ§ν₯", true));
subjectList.add(new Subject("Spring", true));
subjectList.add(new Subject("JPA", true));
subjectList.add(new Subject("MySQL", true));
subjectList.add(new Subject("λμμΈ_ν¨ν΄", false));
subjectList.add(new Subject("Spring_Security", false));
subjectList.add(new Subject("Redis", false));
subjectList.add(new Subject("MongoDB", false));
studentStatusMap.put("Green", new ArrayList<Student>());
studentStatusMap.put("Yellow", new ArrayList<Student>());
studentStatusMap.put("Red", new ArrayList<Student>());
}
public void createStudent(String name, String status, List<String> subjectNameList) {
Student student = new Student(name, status);
studentStatusMap.get(status).add(student);
for (String subjectName : subjectNameList) {
student.getSubjectList().add(subjectName);
String key = student.getStudentId() + subjectName;
subjectSet.add(key);
subjectScoreMap.put(key, new ArrayList<SubjectScore>());
}
System.out.println("μκ°μμ΄ λ±λ‘λμμ΅λλ€.");
printStudent(student);
}
public void changeStudent(String id, String name, String status){
for (Student student : studentList)
if(student.getStudentId().equals(id)){
studentStatusMap.get(student.getStatus()).remove(student);
student.setStudentName(name);
student.setStatus(status);
studentStatusMap.get(status).add(student);
printStudent(student);
System.out.println("μμ λμμ΅λλ€.");
break;
}
}
public void deleteStudent (String id) {
for (Student student : studentList)
if(student.getStudentId().equals(id)){
studentList.remove(student);
studentStatusMap.get(student.getStatus()).remove(student);
for (String subject : student.getSubjectList()) {
String key = student.getStudentId() + subject;
subjectSet.remove(key);
subjectScoreMap.remove(key);
}
System.out.println("μκ°μμ΄ μμ λμμ΅λλ€.");
break;
}
}
private void printStudent(Student student){
System.out.printf("ID : %-10s | μ΄λ¦ : %-5s | κ³Όλͺ© : %-30s | μν : %-5s\n",student.getStudentId(), student.getStudentName(), String.join(", ",student.getSubjectList()),student.getStatus());
}
public void printStudentById(String id){
for(Student student : studentList)
if(student.getStudentId().equals(id))
printStudent(student);
}
public void printStudentByStatus(String status){
for(Student student : studentList)
if(student.getStatus().equals(status))
printStudent(student);
}
public void registerScore(String id, String subject, int score){
String key = id + subject;
subjectScoreMap.get(key).add(new SubjectScore(subjectScoreMap.get(key).size()+1,score, calcGrade(score,subject)));
System.out.println("λ±λ‘λμμ΅λλ€.");
}
private char calcGrade(int score, String subject) {
Boolean mandatory = true;
for(Subject subjectName : subjectList)
if(subjectName.getSubjectName().equals(subject))
mandatory = subjectName.isMandatory();
if (mandatory) {
if (score >= 95) return 'A';
else if (score >= 90) return 'B';
else if (score >= 80) return 'C';
else if (score >= 70) return 'D';
else if (score >= 60) return 'F';
else return 'N';
}
else
if (score >= 90) return 'A';
else if (score >= 80) return 'B';
else if (score >= 70) return 'C';
else if (score >= 60) return 'D';
else if (score >= 50) return 'F';
else return 'N';
}
public int getRound(String key){
return subjectScoreMap.get(key).size()+1;
}
private int getAverage(String key){
int sum = 0;
for(SubjectScore subjectScore : subjectScoreMap.get(key))
sum += subjectScore.getScore();
return sum/(subjectScoreMap.get(key).size()+1);
}
public void printScore(String id, String subject){
for(SubjectScore subjectScore : subjectScoreMap.get(id+subject)) {
System.out.printf("%-5s κ³Όλͺ© %dνμ°¨ | %dμ | %cλ±κΈ\n",subject, subjectScore.getRound(), subjectScore.getScore(), subjectScore.getGrade());
}
System.out.printf("%-5s κ³Όλͺ© νκ· : %dμ νκ· λ±κΈ : %cλ±κΈ",subject,getAverage(id+subject),calcGrade(getAverage(id+subject), subject));
}
public void printScoreById(String id){
for(Student student : studentList)
if(student.getStudentId().equals(id))
for(String subject : student.getSubjectList())
printScore(id, subject);
}
public void printScoreByStatus(String status){
String id;
for(Student student : studentList)
if(student.getStatus().equals(status)){
id = student.getStudentId();
for(String subject : student.getSubjectList())
printScore(id, subject);
}
}
public void changeScore(String id, String subject, int round, int score){
for(SubjectScore subjectScore : subjectScoreMap.get(id+subject))
if(subjectScore.getRound() == round) {
subjectScore.setScore(score);
subjectScore.setGrade(calcGrade(score,subject));
System.out.println("λ³κ²½λμμ΅λλ€.");
}
}
}
- νμμ μ΄λ¦, κ³ μ λ²νΈ, μν, μκ°μ€μΈ κ³Όλͺ©λͺ©λ‘μ λ΄κ³ μλ ν΄λμ€
- νμμ λ²νΈλ₯Ό μλμΌλ‘ λΆμ¬νμ¬ κ³ μ ν λ²νΈλ‘ ꡬν
package Resource;
import java.util.*;
public class Student {
private static int NO = 1;
private String studentId;
private String studentName;
private String status;
private final List<String> subjectList = new ArrayList<>();
public Student(String studentName, String status) {
studentId = "STU" + NO;
this.studentName = studentName;
this.status = status;
++NO;
}
public String getStudentId() {
return studentId;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public void setStatus(String status) {
this.status = status;
}
public String getStudentName() {
return studentName;
}
public String getStatus() {
return status;
}
public List<String> getSubjectList() {
return subjectList;
}
}
- κ³Όλͺ©μ μ΄λ¦κ³Ό νμ/μ ν μ¬λΆλ₯Ό λ΄κ³ μλ ν΄λμ€
package Resource;
public class Subject {
private String subjectName;
private boolean isMandatory;
public Subject(String subjectName, boolean isMandatory) {
this.subjectName = subjectName;
this.isMandatory = isMandatory;
}
public String getSubjectName() {
return subjectName;
}
public boolean isMandatory() {
return isMandatory;
}
}
- κ³Όλͺ©μ νμ°¨, μ μ, λ±κΈμ λ΄κ³ μλ ν΄λμ€
package Resource;
public class SubjectScore {
private int round;
private int score;
private char grade;
public SubjectScore(int round, int score, char grade) {
this.round = round;
this.score = score;
this.grade = grade;
}
public int getRound() {
return round;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public char getGrade() {
return grade;
}
public void setGrade(char grade) {
this.grade = grade;
}
}
- λ°λ³΅νμ¬ μΆλ ₯λλ νλ©΄ UIλ₯Ό λ΄κ³ μλ ν΄λμ€
package Screen;
import java.util.HashMap;
import java.util.Map;
public class ScreenData {
private final Map<ScreenStage, String> screenMap = new HashMap<>();
public ScreenData() {
initScreenMap();
}
public String getStringData(ScreenStage screenStage) {
return screenMap.get(screenStage);
}
private void initScreenMap() {
screenMap.put(ScreenStage.MAIN_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
1. μκ°μ κ΄λ¦¬
2. μ μ κ΄λ¦¬
3. νλ‘κ·Έλ¨ μ’
λ£
==================================
"""
);
screenMap.put(ScreenStage.STUDENT_MAIN_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μκ°μ κ΄λ¦¬ νμ΄μ§μ
λλ€.
1. μκ°μ λ±λ‘
2. μκ°μ μ‘°ν
3. μκ°μ μμ
4. μκ°μ μμ
5. λ€λ‘κ°κΈ°
==================================
""");
screenMap.put(ScreenStage.STUDENT_REGISTER_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μκ°μ λ±λ‘ νμ΄μ§μ
λλ€.
""");
screenMap.put(ScreenStage.STUDENT_INQUIRE_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μκ°μ μ‘°ν νμ΄μ§μ
λλ€.
""");
screenMap.put(ScreenStage.STUDENT_CHANGE_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μκ°μ μμ νμ΄μ§μ
λλ€.
""");
screenMap.put(ScreenStage.STUDENT_DELETE_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μκ°μ μμ νμ΄μ§μ
λλ€.
""");
screenMap.put(ScreenStage.SCORE_MAIN_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μ μ κ΄λ¦¬ νμ΄μ§μ
λλ€
1. μ μ μ
λ ₯
2. μ μ μ‘°ν
3. μ μ μμ
4. λ€λ‘κ°κΈ°
==================================""");
screenMap.put(ScreenStage.SCORE_REGISTER_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μ μ μ
λ ₯ νμ΄μ§μ
λλ€
""");
screenMap.put(ScreenStage.SCORE_INQUIRE_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μ μ μ‘°ν νμ΄μ§μ
λλ€
""");
screenMap.put(ScreenStage.SCORE_CHANGE_MENU,
"""
==================================
λ΄μΌλ°°μμΊ ν μ€νλ§ μκ°μ κ΄λ¦¬ νλ‘κ·Έλ¨
==================================
μ μ μμ νμ΄μ§μ
λλ€
""");
}
}
- ScreentData ν΄λμ€κ° λ΄κ³ μλ νλ©΄μ ꡬλ³νλ μλ³μλ₯Ό λ΄κ³ μλ enumerationν΄λμ€
package Screen;
public enum ScreenStage {
MAIN_MENU,
STUDENT_MAIN_MENU,
STUDENT_REGISTER_MENU,
STUDENT_INQUIRE_MENU,
STUDENT_CHANGE_MENU,
STUDENT_DELETE_MENU,
SCORE_MAIN_MENU,
SCORE_REGISTER_MENU,
SCORE_INQUIRE_MENU,
SCORE_CHANGE_MENU,
}
μ¬μ€μ μ΄μ μ μ§νν Javaλ‘ ν€μ€μ€ν¬λ₯Ό ꡬννλ νλ‘μ νΈμ κ±°μ μ μ¬νλ€.
νμ§λ§ ννλ‘μ νΈμΈ λ§νΌ Githubλ₯Ό μ¬μ©νλ κ²½νμ μ£Όλ €κ³ λ§λ νλ‘μ νΈμλ€.
μ΄ νλ‘μ νΈλ λΉλ‘ μ°λ¦¬ νμ μ½λκ° μλ, μ°λ¦¬νμ μ½λλ₯Ό κ°μ νμ¬ νΌμ λ€μ λ§λ κ±°μ§λ§,
κ°μΈμ μΌλ‘ Mapλ λ°°μ°κ³ , Javaμ λν μ§μκ³Ό κΈ°μ μ΄ λ λ°μ νκ±°κ°μ λ§€μ° λ§μ‘±μ€λ¬μ λ€.
λ€μμ£ΌλΆν°λ λλμ΄ λ°±μλμ λν΄ λ°°μ°κ² λλ€.
μ§κΈκΉμ§ μ€λΉμ΄λ λ¨κ³μλ€κ³ μκ°νκ³ , μ²μ λ°°μ보λ Spring μ΄μ¬ν 곡λΆν΄μΌκ² λ€ :)