Skip to content

Latest commit

 

History

History
49 lines (43 loc) · 1.51 KB

File metadata and controls

49 lines (43 loc) · 1.51 KB

import java.util.Scanner; //package import java.util.ArrayList; //package

class Todo{ //to dolist class 생성 String title; int id; String dday; }

public class Main { //껍데기 public static void main(String[] args) { Scanner sc = new Scanner(System.in); //main안에 input을 받을 Scanner 객체 생성 ArrayList todos = new ArrayList<>(); System.out.print("do you want to creat to do list?(yes/no) : "); String start = sc.nextLine(); //다음 라인을 읽는 코드 if(start.equalsIgnoreCase("yes")) { int number = 1; while(true) { Todo t = new Todo();

			t.id = number;
			System.out.print("type the task: ");
			t.title = sc.nextLine(); //type the task 다음에 들어오는 정보를 입력받는다
			System.out.print("type the D-day: ");
			t.dday = sc.nextLine(); //type the task 다음에 들어오는 정보를 입력받는다
			
			todos.add(t); //todolist 안에 넣는다 위에서 설정한 ArrayList를 통해 todo 에 담을 수 있다
			number++; //연번 추가
			System.out.print("If you want to make more lists?(yes/no) : ");
			String answer = sc.nextLine();
			if(!answer.equalsIgnoreCase("yes")) {
				break;
			}
		}
		System.out.println();
		System.out.println("[To DO LIST]");
		for (int i = 0; i < todos.size(); i++) { //입력 받은 to do list를 쭉 뽑아내기
			Todo t = todos.get(i);
			System.out.println(t.id + ". "+ t.title + " (D-" +t.dday + ")");
		}
	}	
	else {
			System.out.println("Exit the program");
	}
		sc.close();

}

}