freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

對(duì)設(shè)計(jì)模式的理解-資料下載頁

2025-06-30 00:24本頁面
  

【正文】 Tree(String name) { =name。 =null。 =null。 } public Component addChild(Component leftChild,Component rightChild){ =leftChild。 =rightChild。 return this。 } public String getName(){ return name。 } public void getTreeInfo() { ( this tree39。s name is +getName())。 if( instanceof Leaf) { (getName()+39。s left child is +()+,it is a Leaf)。 } if( instanceof Tree){ (getName()+39。s left child is +()+,it is a Tree)。 ()。 } if(==null) { (getName()+39。s left child is a null)。 } if( instanceof Leaf) { (getName()+39。s right child is +()+,it is a Leaf)。 } if( instanceof Tree) { (getName()+39。s right child is +()+,it is a Tree)。 ()。 } if(==null) { (getName()+39。s right child is a null)。 } //(getName()+39。s 高度 是 +getLength())。 } public int getLength() { if(==null) { if(==null) return 1。 else return ()+1。 } else { if(==null) { return ()+1。 } else { if((())=(())) return ()+1。 else return ()+1。 } } } public static void main(String[] args) { }}/*******************************************/package binarytree。public class Leaf extends Component{ private String name。 private Component leaf=null。 public Leaf(String name) { =name。 } public Component addLeftChild(Component leftChild){ return this。 } public Component addRightChild(Component rightChild){ return this。 } public Component addChild(Component leftChild,Component rightChild){ return this。 } public String getName(){ return name。 } public int getLength() { return 1。 } public static void main(String[] args) { // Leaf leaf1 = new Leaf()。 }}/*********************************************************/package binarytree。public class Test { public Test() { } public static void main(String[] args) { Component tree=new Tree(luopeng)。 Component leaf_child=new Leaf(luopeng1)。 Component right_child=new Leaf(luopeng2)。 tree=(leaf_child,right_child)。 //tree=(right_child)。 ()。 Component tree1=new Tree(luopeng2)。 (tree,leaf_child)。 ()。 Component tree2=new Tree(luopeng3)。 (tree,null)。 ()。 Component tree4=new Tree(luopeng4)。 (null,tree)。 ()。 (()+39。s gaodu shi +())。 }}14, Mediator 模式理解 用于一系列關(guān)于對(duì)象交互行為,用一個(gè)中介對(duì)象 public interface Mediator{ } public class ConcreateMediator implements Midiator{ private Member m1=new ConcreateMember1()。 private Member m2=new ConcreateMember2()。 public void operation{ //比如說把m1的成員變量和m2的成員變量互換 } } public class Member{ private Mediator mediator。 public Mddiator getMediator() { return mediator。 } public void setMediator(Mediator mediator) =mediator。 } public class ConcreateMember1 extends Member{ } public class ConcreateMember2 extends Member{ }/******************************/GOF經(jīng)典賞析模式與多態(tài)   Factory Method實(shí)現(xiàn)了創(chuàng)建的多態(tài)Prototype實(shí)現(xiàn)了拷貝的多態(tài)。Builder實(shí)現(xiàn)了創(chuàng)建過程的多態(tài)/******************************/GOF片段賞析 1,Decrator 模式不同于Adapter模式,因?yàn)檠b飾僅改變對(duì)象的職責(zé)而不改變它的接口,而適配器將給對(duì)象一個(gè)全新的接口。 2,Composite模式:可以將裝飾視為一個(gè)退化的、僅有一個(gè)組件的組合。然而,裝飾僅給對(duì)象添加一些額外的職責(zé)它的目的不是在于對(duì)象聚集 3,Strategy模式:用一個(gè)裝飾你可以改變對(duì)象的外殼,而Strategy模式使得你可以改變對(duì)象的內(nèi)核,這是改變對(duì)象的兩種途徑。/*******************************/ 模式該錯(cuò)以下說法有什么錯(cuò)誤??Singleton模式: Singleton模式主要作用是保證在Java應(yīng)用程序中,一個(gè)Class只有一個(gè)實(shí)例存在。 一般有三種方法: 1 定義一個(gè)類,它的構(gòu)造函數(shù)為private的,所有方法為static的。 其他類對(duì)它的引用全部是通過類名直接引用。例如: public final class Math { /** * Don39。t let anyone instantiate this class. */ private Math() {} public static int round(float a) { return (int)floor(a + )。 } ... } 2 定義一個(gè)類,它的構(gòu)造函數(shù)為private的,它有一個(gè)static的private的該類變量,在類初始化時(shí) 實(shí)例話,通過一個(gè)public的getInstance方法獲取對(duì)它的引用,繼而調(diào)用其中的方法。例如: public class Runtime { private static Runtime currentRuntime = new Runtime()。 public static Runtime getRuntime() { return currentRuntime。 } ... } 3 定義一個(gè)類,它的構(gòu)造函數(shù)為private的,它有一個(gè)static的private的boolean變量,用于表示 是否有實(shí)例存在。例如: class PrintSpooler { //this is a prototype for a printerspooler class //such that only one instance can ever exist static boolean instance_flag=false。 //true if 1 instance public PrintSpooler() throws SingletonException { if (instance_flag) throw new SingletonException(Only one spooler allowed)。 else instance_flag = true。 //set flag for 1 instance (spooler opened)。 } // public void finalize() { instance_flag = false。 //clear if destroyed }} /**************** 改錯(cuò)結(jié)束 ******************/面向?qū)ο蟮脑瓌t1,The Open/Closed Principle (OCP) 2,The Liskov Substitution Principle (LSP) 3,The Dependency Inversion Principle (DIP) 4,The Interface Segregation Principle (ISP)5,The Reuse/Release Equivalency Principle (REP) 6,The Common Closure Principle (CCP)7,The Common Reuse Principle (CRP) 8,The Acyclic Dependencies Principle (ADP) 9,The Stable Abstractions Principle (SA
點(diǎn)擊復(fù)制文檔內(nèi)容
電大資料相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1