UML基本概念介绍:
UML:UML (Unified Modeling Language)为面向对象软件设计提供统一的、标准的、可视化的建模语言。适用于描述以用例为驱动,以体系结构为中心的软件设计的全过程。
package dim.uml.generalization; /* * ClassA extends classB , ClassA is_a ClassB */ public class ClassA extends ClassB{ public ClassA() { // TODO Auto-generated constructor stub } } class ClassB { public ClassB() { // TODO Auto-generated constructor stub } }
<span style="font-size:14px;">package dim.uml.generalization; public interface InterfaceA { void doSometingInA(); }</span>
<span style="font-size:14px;">package dim.uml.generalization; public interface InterfaceB extends InterfaceA{ void doSometingInB(); } </span>
<span style="font-size:14px;">package dim.uml.generalization; public class TestInterface implements InterfaceB{ @Override public void doSometingInA() { // TODO Auto-generated method stub } @Override public void doSometingInB() { // TODO Auto-generated method stub } } </span>
<span style="font-size:14px;">package dim.uml.realization; public interface Interface_A { void doSomething(); } </span>
<span style="font-size:14px;">package dim.uml.realization; public class Class_A implements Interface_A { @Override public void doSomething() { // TODO Auto-generated method stub } } </span>
<span style="font-size:14px;">package dim.uml.dependency; public class Programmer { Computer computer=null; public Programmer() { computer=new Computer(); } public void coding() { computer.runCode(computer); } } </span>
<span style="font-size:14px;">package dim.uml.dependency; public class Computer { Computer() { } public void recordCode() { System.out.println("record code now"); } public void compileCode() { System.out.println("compile code now"); } public void runCode(Computer com) { com.recordCode(); com.compileCode(); System.out.println("run code now"); } public void setHeadWare(String HeadWare) { System.out.println("set the headware of computer"); } } </span>
<span style="font-size:14px;">package dim.uml.dependency; public class TestClass { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Programmer pr=new Programmer(); pr.coding(); } } </span>
package dim.uml.association; public class Computer { KeyBoard keyBoard=null; Computer(String Name) { System.out.println(Name+" computer"); keyBoard=new KeyBoard(); } public void surfing() { keyBoard.type(); System.out.println("surfing "); } }
package dim.uml.association; public class KeyBoard { public KeyBoard() { // TODO Auto-generated constructor stub } public void type() { System.out.println("typing"); } }
package dim.uml.association; public class TestAssociation { public static void main(String[] args) { Computer com=null; com=new Computer("FAKE"); com.surfing(); } }
参考资料:
《StartUML详解教程》
目前水平甚微,有所不足,多多指正,共同进步!
原文地址:http://blog.csdn.net/androidolblog/article/details/45046425