写点什么

架构师 -Week3- 作业

用户头像
龙7
关注
发布于: 2020 年 06 月 24 日

作业一

作业二

package com.yx.jktrain.week3;

import java.util.ArrayList;
import java.util.List;

/**
* @author yanx
* @date 2020-06-24 6:22
*/

interface INodeManage {
void addNode(INodeManage node);

void removeNode(INodeManage node);

void print();
}

//WinForm
public class WinForm implements INodeManage {

private String nodeName;

public WinForm(String nodeName) {
this.nodeName = nodeName;
}

List<INodeManage> nodeList = new ArrayList<INodeManage>();

@Override
public void addNode(INodeManage node) {
nodeList.add(node);
}

@Override
public void removeNode(INodeManage node) {
nodeList.remove(node);
}

@Override
public void print() {
System.out.println("print WinForm(" + nodeName + ")");
for (INodeManage node : nodeList) {
node.print();
}
}

public static void main(String[] args) {
//create nodes
WinForm winForm = new WinForm("WINDOW窗口");
winForm.addNode(new Picture("LOGO图片"));
winForm.addNode(new Button("登录"));
winForm.addNode(new Button("注册"));
Frame frame = new Frame("FRAME1");
frame.addNode(new Lable("用户名"));
frame.addNode(new TextBox("文本框"));
frame.addNode(new Lable("密码"));
frame.addNode(new PasswordBox("密码框"));
frame.addNode(new CheckBox("复选框"));
frame.addNode(new TextBox("记住用户名"));
frame.addNode(new LinkLable("忘记密码"));
winForm.addNode(frame);
//print
winForm.print();

}
}

//Picture
class Picture implements INodeManage {

private String nodeName;

public Picture(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print Picture(" + nodeName + ")");
}
}

//Button
class Button implements INodeManage {

private String nodeName;

public Button(String nodeName) {
this.nodeName = nodeName;
}


@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print Button(" + nodeName + ")");
}
}

//Frame
class Frame implements INodeManage {
private String nodeName;

List<INodeManage> nodeList = new ArrayList<INodeManage>();

public Frame(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {
nodeList.add(node);
}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print Frame(" + nodeName + ")");
for (INodeManage node : nodeList) {
node.print();
}
}
}

//Lable
class Lable implements INodeManage {
private String nodeName;

public Lable(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print Lable(" + nodeName + ")");
}
}

//TextBox
class TextBox implements INodeManage {
private String nodeName;

public TextBox(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print TextBox(" + nodeName + ")");
}
}

//PasswordBox
class PasswordBox implements INodeManage {
private String nodeName;

public PasswordBox(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print PasswordBox(" + nodeName + ")");
}
}

//CheckBox
class CheckBox implements INodeManage {
private String nodeName;

public CheckBox(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print CheckBox(" + nodeName + ")");
}
}

//LinkLable
class LinkLable implements INodeManage {
private String nodeName;

public LinkLable(String nodeName) {
this.nodeName = nodeName;
}

@Override
public void addNode(INodeManage node) {

}

@Override
public void removeNode(INodeManage node) {

}

@Override
public void print() {
System.out.println("print LinkLable(" + nodeName + ")");
}
}



输出:

print WinForm(WINDOW窗口)

print Picture(LOGO图片)

print Button(登录)

print Button(注册)

print Frame(FRAME1)

print Lable(用户名)

print TextBox(文本框)

print Lable(密码)

print PasswordBox(密码框)

print CheckBox(复选框)

print TextBox(记住用户名)

print LinkLable(忘记密码)



用户头像

龙7

关注

还未添加个人签名 2019.02.12 加入

还未添加个人简介

评论

发布
暂无评论
架构师-Week3-作业