1 Star 0 Fork 0

juniperwu/JavaPattern

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
MainHost.java 909 Bytes
Copy Edit Raw Blame History
wujf authored 2016-09-15 23:54 +08:00 . inti by wujf
package com.pattern.composite;
import java.util.*;
public class MainHost implements IComputerDevice {
String name;
boolean isHost;
double price;
LinkedList<IComputerDevice> list;
MainHost(String name,double price){
this.name = name;
this.isHost = true;
this.price = price;
list = new LinkedList<IComputerDevice>();
}
@Override
public void Add(IComputerDevice device) {
list.add(device);
}
@Override
public void Remove(IComputerDevice device) {
list.remove(device);
}
@Override
public IComputerDevice getDeviceAt(int index) {
return list.get(index);
}
@Override
public Iterator<IComputerDevice> getAllDevice() {
return list.iterator();
}
@Override
public boolean isHost() {
return this.isHost;
}
@Override
public double getPrice() {
return this.price;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return this.name;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/mygit2008/JavaPattern.git
git@gitee.com:mygit2008/JavaPattern.git
mygit2008
JavaPattern
JavaPattern
master

Search