zoukankan      html  css  js  c++  java
  • VS2010 生成序列图实例

    今天我用一个非常非常简单的代码实例来体验一下VS2010生成序列图的过程:很简单,希望大家不要拍砖啊:)

    例子:声明一个学生类,一个课程类,在主程序中让学生学一个课,就这么简单:)上代码:

    课程类:

     using System;

    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Course
        {
            public string CourseName { getset; }

            public void ResetCouseName()
            {
                this.CourseName = "R&S";
            }
        }
    }

    学生类:

     using System;

    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Student
        {
            public string StudentName { getset; }

            public List<Course> SelectedCouses = new List<Course>();

            public void AddCourse(Course c)
            {

                this.SelectedCouses.Add(c);
            }

            public void ResetAllTheCourse()
            {
                foreach (var item in SelectedCouses)
                {
                    item.ResetCouseName();
                }
            }
        }
    }

    程序入口:

     using System;

    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Student s = new Student();
                Course chineseCourse = new Course();
                chineseCourse.CourseName = "Chinese";

                Course englishCourse = new Course();
                englishCourse.CourseName = "english";

                s.AddCourse(chineseCourse);
                s.AddCourse(englishCourse);

                foreach (Course item in s.SelectedCouses)
                {
                    Console.WriteLine(item.CourseName);   
                }
                Console.Read();
            }
        }
    }

    最后,如果点击生成序列图

     

    然后得到图: 

     

    然后结束,至于序列图是什么概念,有图有真相,看图就可以明白怎么玩的了:) 

  • 相关阅读:
    Comet OJ
    LOJ#2719. 「NOI2018」冒泡排序 DP+组合+树状数组
    LuoguP6747 『MdOI R3』Teleport 二进制+贪心
    LuoguP6748 『MdOI R3』Fallen Lord 树形DP+set
    LuoguP5576 [CmdOI2019]口头禅 后缀树+线段树+暴力
    LOJ#3161. 「NOI2019」I 君的探险 整体二分+随机化+二进制分组
    LOJ#2085. 「NOI2016」循环之美 莫比乌斯反演+杜教筛
    LuoguP5327 [ZJOI2019]语言 线段树合并+树链求并
    【考试题
    ELK
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/2379714.html
Copyright © 2011-2022 走看看