2013년 2월 26일 화요일

7일차- 배열2

public class CarFactoryMain {


public static void main(String[] args) {

Car matiz = new Car();
matiz.setModel("matiz");
matiz.setDoorCount(4);

Engine mEngine = new Engine();
mEngine.setType("A");
mEngine.setCc(1000);
matiz.setEngine(mEngine);

matiz.print();

}

}
----------------------------------------------------

public class Car {

private String model;
private int doorCount;
/****engine****/
private Engine engine;
/**************/

public void setData(String model, int doorCount, Engine engine){
this.model=model;
this.doorCount=doorCount;
this.engine=engine;
}
public void print(){
System.out.println("모델:"+this.model);
System.out.println("문수:"+this.doorCount);
/*
System.out.println("엔진타입:"+this.engine.getType());
System.out.println("엔진배기량:"+this.engine.getCc());
*/
engine.print();
}
/*
public String getInfo(){
return ""+model+"\t"+doorCount+"\t"+"engine";
}
*/
public void setEngine(Engine engine)  {
this.engine=engine;
}
public Engine getEngine()  {
return this.engine;
}
public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public int getDoorCount() {
return doorCount;
}

public void setDoorCount(int doorCount) {
this.doorCount = doorCount;
}
}
--------------------------------------------------------
public class Engine {

private String type;//엔진의 타입
private int cc;  //엔진의 배기량
public void print(){
System.out.println(this.type);
System.out.println(this.cc);
/*
* String getInfo = this.getInfo();
*
*System.out.println(getInfo);
*/
}
/*
public String getInfo()  {
return type+"\t"+cc;
}
*/
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getCc() {
return cc;
}
public void setCc(int cc) {
this.cc = cc;
}
}

댓글 3개:

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...