package com.newlecture.game;


public class Program {


public static void main(String[] args) 

{

MenuView menuView = new MenuView();

GameView gameView = new GameView();

RankingView rankingView = new RankingView();

menuView.print();

int menu = menuView.input();

switch(menu)

{

case 1 :

gameView.print();

break;

case 2 :

rankingView.print();

break;

case 3 :

System.out.println("종료합니다");


break;

}

}


}



package oop.instance;


public class Record {

int kor;

int eng;

int math;

public Record() //생성자

{

this.kor =2;

this.eng=3;

this.math=4;

}

public int total()

return this.kor + this.eng + this.math;

}

public int getKor()  //설정자

{

return this.kor;

}


public int getEng()

{

return this.eng;

}

public int getMath()

{

return this.math;

}

public void setKor(int kor) //설정자

{

this.kor=kor;

}


public void setEng(int eng)

{

this.eng=eng;

}

public void setMath(int math)

{

this.math=math;

}

}




package oop.capsule;

import java.util.Scanner;

public class RecordView 
{

	
	static int inputMenu() //메뉴출력함수
	{
		Scanner scan= new Scanner(System.in);
		int menu;
		
		System.out.println("┌─────────────────┐");
		System.out.println("│                   메인  메뉴                  │");
		System.out.println("└─────────────────┘");
		System.out.print("\t\t1.성적 입력\n");
		System.out.print("\t\t2.성적 출력\n");
		System.out.print("\t\t3.종료\n");
		menu = scan.nextInt();
		
		return menu;
		
		
	}
	
	
	static void inputRecord(Record record) //성적입력함수
	{
		Scanner scan= new Scanner(System.in);
		int kor, eng, math; //임시변수선언
		
						System.out.println("┌─────────────────┐");
						System.out.println("│                   성적  입력                  │");
						System.out.println("└─────────────────┘");

						
					do{
							System.out.println("\t\t국어 :");
							kor = scan.nextInt();
							if(kor<0 || kor>100)
								System.out.println("범위벗어남");
						}
						while(kor<0 || kor>100);
						
					
					do{
							System.out.print("\t\t영어 :");
							eng = scan.nextInt();
							if(eng<0 || eng>100)
								System.out.println("범위벗어남");
						}
					while(eng<0 || eng>100);

					
					do{
							System.out.print("\t\t수학 :");
							math = scan.nextInt();
							if(math<0 || math>100)
								System.out.println("범위벗어남");
						}
					while(math<0 || math>100);
					
					Record.setKor(record,kor);
					Record.setEng(record,eng);
					Record.setMath(record,math);
					
				
					
					
	}
	
	static void printRecord(Record record)//성적출력함수
	{
					
						int total = Record.total(record);
						float avg = total / 3.0f;	
									
						System.out.printf("┌─────────────────┐\n");
						System.out.printf("│           @본인 이름 성적표@           │\n");
						System.out.printf("├──┬──┬──┬──┬──┬──┤\n");
						System.out.printf("│번호│국어│영어│수학│총점│평균│\n");
					for(int i=0 ; i<3 ; i++)
						{
							System.out.printf("├──┼──┼──┼──┼──┼──┤\n");
							System.out.printf("│%-5d│%-5d│%-5d│%-5d│%-5d│%4.2f│\n",
									i+1,Record.getKor(record),Record.getEng(record),Record.getMath(record),total,avg);
						}
						System.out.printf("└──┴──┴──┴──┴──┴──┘\n");
	}
	
}



package oop.capsule;

import java.util.Scanner;

import oop.capsule.Record;

public class Program2
{
	
	public static void main(String[] args) 
	{
		Record record = new Record();
		
		
/*		int kor=0;
		int eng=0;
		int math=0;*/
		int menu;
		int i;
		
		Scanner scan = new Scanner(System.in);
		
		exit:while(true)
		{
			/*menu = inputMenu();*/
			
/*			System.out.println("┌─────────────────┐");
			System.out.println("│                   메인  메뉴                  │");
			System.out.println("└─────────────────┘");
			System.out.print("\t\t1.성적 입력\n");
			System.out.print("\t\t2.성적 출력\n");
			System.out.print("\t\t3.종료\n");
			menu = scan.nextInt();*/
		
			switch(menu = RecordView.inputMenu())
			{
			
			case 1:
				
				RecordView.inputRecord(record);
			
	
					//inputRecord(kor,eng,math);
/*					System.out.println("┌─────────────────┐");
					System.out.println("│                   성적  입력                  │");
					System.out.println("└─────────────────┘");

					
				do{
						System.out.println("\t\t국어 :");
						kor = scan.nextInt();
						if(kor<0 || kor>100)
							System.out.println("범위벗어남");
					}
					while(kor<0 || kor>100);
					
				
				do{
						System.out.print("\t\t영어 :");
						eng = scan.nextInt();
						if(eng<0 || eng>100)
							System.out.println("범위벗어남");
					}
				while(eng<0 || eng>100);

				
				do{
						System.out.print("\t\t수학 :");
						math = scan.nextInt();
						if(math<0 || math>100)
							System.out.println("범위벗어남");
					}
				while(math<0 || math>100);
				*/
				break;

				
			case 2:
				
				RecordView.printRecord(record);
				
					/*total = kor + eng + math;
					avg = total / 3.0f;	
								
					System.out.printf("┌─────────────────┐\n");
					System.out.printf("│           @본인 이름 성적표@           │\n");
					System.out.printf("├──┬──┬──┬──┬──┬──┤\n");
					System.out.printf("│번호│국어│영어│수학│총점│평균│\n");
				for(i=0 ; i<3 ; i++)
					{
						System.out.printf("├──┼──┼──┼──┼──┼──┤\n");
						System.out.printf("│%-5d│%-5d│%-5d│%-5d│%-5d│%4.2f│\n",i+1,kor,eng,math,total,avg);
					}
					System.out.printf("└──┴──┴──┴──┴──┴──┘\n");*/
				
					break;
					
			case 3:
				
					System.out.println("프로그램이 종료됩니다.");	
					break exit;
					
			default:
					System.out.println("입력 오류");
			}
		}
	}
}
	

+ Recent posts