728x90
반응형
💾MainClass 클래스
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) {
Cat c = new Cat();
c.set_name("검둥이");
c.set_color("black");
Scanner s = new Scanner(System.in);
System.out.println(c.get_name() + "의 정보!\n털 색 : " + c.get_color());
System.out.println(c.get_name() + "의 호기심의 정도를 입력하세요.");
c.set_curio(s.nextInt());
System.out.println(c.curio_rank());
}
}
💾Cat클래스
public class Cat {
String name; // 이름
String color; // 털 색상
int curio = 0; // 호기심 정도
void set_name(String n) {
name = n;
}
void set_color(String c) {
color = c;
}
void set_curio(int cu) {
curio = cu;
}
String get_name() {
return name;
}
String get_color() {
return color;
}
String curio_rank() {
String str = null;
if(curio < 20) {
str = "무서워요! 도망치기";
}
else if(curio < 40) {
str = "경계중! 털 곤두 세우기";
}
else {str = "야옹! 인사해요";}
return str;
}
}
728x90
반응형
'Project > Study | etc' 카테고리의 다른 글
Team Project - 계산기 프로그램 (0) | 2022.07.01 |
---|---|
상품 구매 프로그램 (0) | 2022.06.29 |
성적 관리 프로그램 + 설계, 메소드 구현 (0) | 2022.06.28 |
랜덤 카드 추출 게임 (0) | 2022.06.26 |
성적 관리 프로그램 (0) | 2022.06.23 |
댓글