This commit is contained in:
zaien24 2020-08-26 19:37:04 +09:00
parent a5a1dea50f
commit d626f2f9b1
4 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,11 @@
package org.springframework.samples.petclinic.proxy;
public class Cash implements Payment {
@Override
public void pay(int amount) {
System.out.println(amount + "현금 결재" );
}
}

View file

@ -0,0 +1,14 @@
package org.springframework.samples.petclinic.proxy;
public class CreditCard implements Payment {
Payment cash = new Cash();
@Override
public void pay(int amount) {
if (amount > 100) {
System.out.println(amount + " 신용 카드");
} else {
cash.pay(amount);
}
}
}

View file

@ -0,0 +1,6 @@
package org.springframework.samples.petclinic.proxy;
public interface Payment {
void pay(int amount);
}

View file

@ -0,0 +1,14 @@
package org.springframework.samples.petclinic.proxy;
public class Store {
Payment payment;
public Store(Payment payment) {
this.payment = payment;
}
public void buySomething() {
payment.pay(100);
}
}