-
인터페이스 (자바)과거...../자바 2009. 2. 22. 19:44
//importation 인터페이스
public interface Importation {
public abstract double calculate_traiff();
}
//Sale 인터페이스
public interface Sale {
public abstract double calculate_tax();
}
//Car 클래스
public class Car implements Importation, Sale {
String make;
String model;
int year;
int max_speed;
float price;
public double getTotalPrice(){
return (price + calculate_traiff() + calculate_tax());
}
public double calculate_traiff() {
return price*0.1;
}
public double calculate_tax() {return price*0.3;
}}
//Clotaes 클래스
public class Clotaes implements Importation, Sale {
String make;
String model;
float price;
public double getTotalPrice() {
return (price + calculate_traiff() + calculate_tax());
}@Override
public double calculate_traiff() {
return (price*0.05);
}
public double calculate_tax(){
return price*0.2;
}}