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

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

     

    然后得到图: 

     

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

  • 相关阅读:
    送给每天用电脑超4小时的朋友!!
    股票技术指标分析详细
    2003安装新版MSN9的方法 / MSN9 for 2003
    买卖股票基本原则新手参考
    更改Windows软件默认安装路径
    永不套牢的方法(教你正确止损)
    股票的技术参数很多,图线参数常见的有这些
    教育网ftp大全
    【笔记】【汇编语言】第4章 第一个程序
    【笔记】【汇编语言】第2章 寄存器
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/2379714.html
Copyright © 2020-2023  润新知