package com.Summer_0427.cn;
/**
* @author Summer
* 接口和多继承之间的关系和应用
* 应用实例:计算机及其设备、插排与两项电和三项电的应用;
计算机作为商品的继承
*/
interface ThreeElectronic{
void threeService();
}
interface TwoElectronic{
void twoService();
}
//接口的继承和多继承,实现了接口的功能合并和
interface Socket extends ThreeElectronic,TwoElectronic{
void socketService();
}
class goods{
private String type;
public goods(String type) {
this.type = type;
}
public String getType() {
System.out.println(this.type+"属于家电类");
return type;
}
}
class Computer extends goods implements Socket{
public Computer(String type) {
super(type);
}
@Override
public void threeService() {
System.out.println("计算机本身用三项电通电");
}
@Override
public void twoService() {
System.out.println("计算机上的外置设备用两项电通电");
}
@Override
public void socketService() {
System.out.println("计算机上连接的插排进行供电");
}
}
public class TestElectronic {
public static void main(String[] args) {
Computer cp = new Computer("戴尔电脑");
cp.threeService();
cp.twoService();
cp.socketService();
cp.getType();
}
}