package ch02;
public class Car {
String name;
int price;
Engine engine;
public Car(String name, int price) {
this.name = name;
this.price = price;
this.engine = new Engine("GDI", 500);
}
public void showInfo() {
System.out.println("name : " + name);
System.out.println("price : " + price);
}
}
package ch02;
public class Engine {
String name;
int price;
public Engine(String name, int price) {
this.name = name;
this.price = price;
}
public void showInfo() {
System.out.println("name : " + name);
System.out.println("price : " + price);
}
}
'Java > Excercise' 카테고리의 다른 글
interface ch02 HomeAppliances (0) | 2021.08.31 |
---|---|
interface ch01 HomeAppliances (0) | 2021.08.31 |
abstract ch03 Car (0) | 2021.08.30 |
abstract ch02 Computer (0) | 2021.08.30 |
abstract ch01 Animal (0) | 2021.08.30 |