Responsibility chain Test Java class

Source: Internet
Author: User
Package com.wd.test.state;


Import java.util.ArrayList;
Import java.util.List;


public class Stautslinktest {


public static void Main (string[] args) {
Stautslinktest test = new Stautslinktest ();
Test.test ();
}
Public String name= "Com.wd.test.state.BL";
public void Test () {
list<l> ls = new arraylist<l> ();
Ls.add (New AL ());
Ls.add (New BL ());
Ls.add (New CL ());
Ls.add (New DL ());
Ls.add (New EL ());
Ls.add (New FL ());
Ls.add (New GL ());
Ls.add (New HL ());
Ls.add (New IL ());
Ls.add (New JL ());

for (int i = 0; i < ls.size (); i++) {
if (Ls.get (i). GetName (). Equals (name)) {
Ls.get (i). Check (name);
}
}
}
}


Class cons{
public static final int a=1;
public static final int b=2;
public static final int c=3;
public static final int d=4;
public static final int e=5;
}


Abstract class l{
A--b--d
--c
D--e--g
--j
--f--h
-I.
protected String name = This.getclass (). GetName ();
protected String prename;

Public String Getprename () {
return prename;
}
public void Setprename (String prename) {
This.prename = Prename;
}
Public String GetName () {
return name;
}
public void SetName (String name) {
THIS.name = name;
}
Public list<l> Getls () {
return LS;
}
public void Setls (list<l> ls) {
This.ls = ls;
}
void Curr () {
System.out.println ("Come to" +this.getclass (). GetName ());
}
void Next () {
}
void Deal (L) {
System.out.println ("Deal" +l.getname ());
}
public void Check (String name) {


for (int i = 0; i < ls.size (); i++) {
if (Ls.get (i). GetName (). Equals (name)) {
Deal (Ls.get (i));
Next ();
}
}
}
List<l> ls=new arraylist<l> ();

}
Class AL extends l{
public void Next () {
Ls.add (New BL ());
Ls.add (New CL ());
}
}
Class BL extends l{
@Override
void Next () {
Ls.add (New DL ());

}
}
Class CL extends l{
@Override
void Next () {
System.out.println ("is to");
}
}
Class DL extends l{
@Override
void Next () {
Ls.add (New EL ());
}
}
Class EL extends l{
@Override
void Next () {
Ls.add (New JL ());
Ls.add (New GL ());
}
}
Class FL extends l{
@Override
void Next () {
Ls.add (New HL ());
Ls.add (New IL ());
}
}
Class GL extends l{
@Override
void Next () {
System.out.println ("It's to");
}
}
Class LL extends l{
@Override
void Next () {
System.out.println ("It's to");
}
}
Class HL extends l{
@Override
void Next () {
System.out.println ("It's to");
}
}
Class IL extends l{
@Override
void Next () {
System.out.println ("It's to");
}
}
Class JL extends l{
@Override
void Next () {
System.out.println ("It's to");
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.