Skip to content

Commit

Permalink
[Week3][Chap12] OCP(Open-Closed Principle) 원칙 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
arinming committed Feb 8, 2024
1 parent 993800e commit 6d184f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 김아린/java-basic/src/poly/car1/CarMain1.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ public static void main(String[] args) {
Model3Car model3Car = new Model3Car();
driver.setCar(model3Car);
driver.drive();

// 차량 변경(model3 -> newCar)
NewCar newCar = new NewCar();
driver.setCar(newCar);
driver.drive();
}
}
18 changes: 18 additions & 0 deletions 김아린/java-basic/src/poly/car1/NewCar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package poly.car1;

public class NewCar implements Car{
@Override
public void startEngine() {
System.out.println("NewCar.startEngine");
}

@Override
public void offEngine() {
System.out.println("NewCar.offEngine");
}

@Override
public void pressAccelerator() {
System.out.println("NewCar.pressAccelerator");
}
}

0 comments on commit 6d184f6

Please sign in to comment.