- 论坛徽章:
- 0
|
Videocard.java
interface Videocard
{
void Display();
String getName();
}
Dmeng.java
class Dmeng implements Videocard
{
String name;
public Dmeng()
{
name="Dmeng's videocard";
}
public void setname(String name)
{
this.name=name;
}
public void Display()
{
System.out.println("Dmeng's videocard is working");
}
public String getName()
{
return name;
}
}
Mainboard.java
class mainboard
{
String strCPU;
Videocard vc;
void setCPU(String strCPU)
{
this.strCPU=strCPU;
}
void setVideocard(Videocard vc)
{
this.vc=vc;
}
void run()
{
System.out.println(strCPU);
System.out.println(vc.getName());
vc.Display();
System.out.println("Mainboard is running");
}
}
Computer.java
class Computer
{
public static void main(String[] args)
{
Dmeng d=new Dmeng();
Mainboard i=new Mainboard();
i.setCPU("ntel's CPU");
i.setVideocard(d);
i.run();
}
}
前三个都编译成功,但在编译第四个时怎么也不成功,问题也不知道出在那?希望那位大侠能帮我解决下! |
|