zoukankan      html  css  js  c++  java
  • 一个典型类的定义和UML图

    【示例】模拟学生使用电脑学习

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    class Computer {
        String brand;  //品牌
    }
    public class SxtStu {
        // field
        int id;
        String sname;
        int age;
        Computer comp;
        void study() {
            System.out.println("我正在学习!使用我们的电脑,"+comp.brand);
        }
        SxtStu() {
        }
        public static void main(String[] args) {
            SxtStu stu1 = new SxtStu();
            stu1.sname = "张三";
            Computer comp1 = new Computer();
             comp1.brand = "联想";
            stu1.comp = comp1;
            stu1.study();
        }
    }

      执行结果:

    1.png

      对应的UML图如下:

    2.png

     SxtStu和Computer的UML类图

  • 相关阅读:
    POJ1034 The dog task
    POJ1033 Defragment
    POJ1032 Parliament
    POJ1031 Fence
    POJ1030 Rating
    POJ1029 False coin
    伪元素的使用
    伪元素选择器:before 以及 :after
    jquery html() 和text()的用法
    用CSS绘制三角形
  • 原文地址:https://www.cnblogs.com/huaxiansheng/p/15310499.html
Copyright © 2011-2022 走看看