package com.test4;
interface Car
{
String getName();
int getPrice();
}
class BMW implements Car
{
public String getName()
{
return "BMW";
}
public int getPrice() {
// TODO Auto-generated method stub
return 300000;
}
}
class CheryQQ implements Car
{
public String getName() {
// TODO Auto-generated method stub
return "CheryQQ";
}
public int getPrice() {
// TODO Auto-generated method stub
return 20000;
}
}
//汽车出售店
public class Demo1
{
private int money=0;
public void sellCar(Car car)
{
System.out.println("车型:"+car.getName()+" 单价:"+car.getPrice());
money+=car.getPrice();
}
public int getMoney()
{
return money;
}
public static void main(String[] args)
{
Demo1 demo1=new Demo1();
demo1.sellCar(new BMW());
demo1.sellCar(new CheryQQ());
System.out.println("总收入:"+demo1.getMoney());
}
}
interface Car
{
String getName();
int getPrice();
}
class BMW implements Car
{
public String getName()
{
return "BMW";
}
public int getPrice() {
// TODO Auto-generated method stub
return 300000;
}
}
class CheryQQ implements Car
{
public String getName() {
// TODO Auto-generated method stub
return "CheryQQ";
}
public int getPrice() {
// TODO Auto-generated method stub
return 20000;
}
}
//汽车出售店
public class Demo1
{
private int money=0;
public void sellCar(Car car)
{
System.out.println("车型:"+car.getName()+" 单价:"+car.getPrice());
money+=car.getPrice();
}
public int getMoney()
{
return money;
}
public static void main(String[] args)
{
Demo1 demo1=new Demo1();
demo1.sellCar(new BMW());
demo1.sellCar(new CheryQQ());
System.out.println("总收入:"+demo1.getMoney());
}
}