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();
            }
        }
    }

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

     

    然后得到图: 

     

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

  • 相关阅读:
    HDU 5977 Garden of Eden(点分治求点对路径颜色数为K)
    HDU 5828 Rikka with Sequence(线段树区间加开根求和)
    TZOJ 1689 Building A New Barn(求平面上有几个其它点求到n个点的曼哈顿距离最小)
    HDU 5734 Acperience(数学推导)
    POJ 1741 Tree(点分治点对<=k)
    HDU 5723 Abandoned country(kruskal+dp树上任意两点距离和)
    HDU 5988 Coding Contest(最小费用最大流变形)
    TZOJ 1693 Silver Cow Party(最短路+思维)
    TZOJ 4602 高桥和低桥(二分或树状数组+二分)
    TZOJ 2099 Sightseeing tour(网络流判混合图欧拉回路)
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/2379714.html
Copyright © 2011-2022 走看看