클래스간 협력 연습 문제 풀기
public class Taxi {
String companyName = "잘나간다 운수";
int income = 0;
int fare = 10000;
void ShowInfo() {
System.out.println(companyName + "택시 수입은 " + income + " 입니다");
}
}
public class Person {
String name = "Edward";
int money = 20000;
void takeTaxt(Taxi taxi)
{
money -= taxi.fare;
taxi.income += taxi.fare;
}
void ShowInfo() {
System.out.println(name + "님의 남은 돈은 " + money + " 입니다");
}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Taxi taxi = new Taxi();
Person person = new Person();
person.takeTaxt(taxi);
person.ShowInfo();
taxi.ShowInfo();
}
}