接口的应用
来源:互联网 发布:软件是怎么设计的 编辑:程序博客网 时间:2024/05/02 06:09
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());
}
}
0 0
- 接口的应用
- 接口测试的应用
- 接口的应用
- 接口测试的应用
- FCKeditorAPI接口的应用
- 接口的小应用
- 接口的应用
- java接口的应用
- 接口的简单应用
- JAVA 接口的应用
- 接口的应用
- 接口的应用
- Java4Android-接口的应用
- java9.接口的应用
- 接口的典型应用
- java29接口的应用
- 接口的应用
- 接口的应用
- 文件和注册表的重定向解决方法
- 与afreez一起学习DSP中浮点转定点运算--浮点数的存储格式
- 第10周项目3-血型统计
- const char*, char const* and char *const
- 优秀Python学习资源收集汇总
- 接口的应用
- 第一个java小游戏,贪吃蛇~真心求改进
- 教你查看预装Win8电脑内置系统激活密钥(Win8 OEM Key)
- 软件架构————设计启发
- workstation 搭建多个虚拟机
- string类中截断函数erase
- 开发中最常用的GitHub上 优秀的 Android 开源项目整理(精品)
- chromium for android v38硬件绘制渲染结构及流程分析(render进程)
- 我反对你,正是对你的支持