public interface CarService{
String getName ();
void drive ();
String color();
}
public class Sedan implements CarService {
private String name;
private String color;
private int speed;
public Sedan(String name, String color,int speed{
this.name = name;
this.color = color;
this.speed = speed;
}
@Override
public String getName() {
return this.name;
}
@Override
public void drive() {
System.out.println("普通的小车普通的开" + this.speed);
}
@Override
public String color() {
return this.color;
}
}
public class FastSedan extends Sedan {
public FastSedan(String name, String color, int speed) {
super(name, color, speed);
}
public void drive() {
System.out.println("飙车的飙,飙起来" + this.getSpeed() * 2);
}
}
public class Boss {
//发布任务给cto
public void pushJob(CTO cto) {
List<Programmer> list = new ArrayList<Programmer>();
for (int i = 0;i < 5;i++) {
list.add(new Programmer());
}
cto.assignmentTask(list);
}
}
public class CTO {
//分配任务
public void assignmentTask(List<Programmer> programmers) {
for (Programmer programmer:programmers) {
programmer.backPot();
}
}
}
public class Programmer {
//背锅
public void backPot () {
System.out.println("程序员背起了小锅");
}
}
public class Client {
public static void main (String []args) {
Boss boss = new Boss();
boss.pushJob(new CTO());
}
}
public class Boss {
//发布任务给cto
public void pushJob(CTO cto) {
cto.assignmentTask();
}
}
public class CTO {
private List<Programmer> programmers;
public CTO(List<Programmer> programmers) {
this.programmers = programmers;
}
public void assignmentTask() {
for (Programmer programmer:programmers) {
programmer.backPot();
}
}
}
public class Programmer {
//背锅
public void backPot () {
System.out.println("程序员背起了小锅");
}
}
public class Client {
public static void main (String []args) {
List<Programmer> programmers = new ArrayList<Programmer>();
for (int i = 0;i < 5;i++) {
programmers.add(new Programmer());
}
Boss boss = new Boss();
boss.pushJob(new CTO(programmers));
}
}
原文发布时间为:2018-09-2
本文作者:小小小咖