

package 연습용패키지;
public class exercise {
//필드
String gameID;
int fuelGauge;
int carSpeed;
//메소드
void show() {
System.out.print("게임ID: " + gameID);
System.out.print("\t 연료: " + fuelGauge);
System.out.println("\t 속도: " + carSpeed);
}
void Accel() {
if (fuelGauge <= 0)
System.exit(0);
else
fuelGauge--;
carSpeed += 10;
}
void Break() {
if (carSpeed < 10) {
carSpeed = 0;
System.exit(0);
carSpeed -= 10;
}
}
public static void main(String[] args) {
System.out.println("ADT&클래스\n");
exercise rider = new exercise();
rider.gameID = "run99";
rider.fuelGauge = 50;
rider.carSpeed = 20;
rider.show();
rider.Accel();
rider.Accel();
rider.show();
rider.Break();
rider.show();
}
}
package 실습;
public class building {
//필드 선언
String name;
int height;
//메소드 선언
public building( ) {};
//창문의 개수를 count하는 메소드
public String Permit() {
String result;
if(height>10) {
result="Do Not Permitted";
}
else {
result="Permitted";
}
return result;
}
//새로운 이름 만드는 메소드
public String newName() {
return "new"+name;
}
public static void main(String[] args) {
building hospital;
hospital=new building();
hospital.name="동국대병원";
hospital.height=43;
String ad=hospital.Permit();
String nn=hospital.newName();
System.out.println("건물높이가"+hospital.height+"의 건물심사 결과는 "+ ad);
System.out.println(hospital.name+"의 새로운 이름은"+nn);
//building
//
//hospital
}
}

교수님 코멘트 : 현실적이게 짜보아라