Chinaunix首页 | 论坛 | 博客
  • 博客访问: 928038
  • 博文数量: 210
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 21:54
文章分类

全部博文(210)

文章存档

2020年(2)

2019年(18)

2018年(27)

2017年(5)

2016年(53)

2015年(88)

2014年(17)

分类: C/C++

2015-10-28 11:54:01


点击(此处)折叠或打开

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. namespace studentFrom
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         Student Mdc;   //定义一个全局的名字
  14.         int index = 0;
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.             Mdc = new Student(        //页面的最初的状态
  19.                           "黑马",
  20.                           "崔牛",
  21.                           "太监",
  22.                           1625
  23.                           );
  24.             richTextBox1.Text = Mdc.StudentInfo();     输出 Mdc的信息
  25.             timer1.Enabled = true;
  26.         }

  27.      
  28.         private void button1_Click(object sender, EventArgs e)
  29.         {
  30.            
  31.         }

  32.         private void button2_Click(object sender, EventArgs e)
  33.         {

  34.             Mdc.ModifyProf("");
  35.             richTextBox1.Text = Mdc.StudentInfo();
  36.            
  37.         }

  38.         private void timer1_Tick(object sender, EventArgs e)      //添加一个时钟进行计数
  39.         {
  40.             index++;
  41.             Mdc.ModifyProf("专业泡妞" + index.ToString() + "年");
  42.             richTextBox1.Text = Mdc.StudentInfo();

  43.         }

  44.        


  45.     }
  46. }





点击(此处)折叠或打开

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;

  5. namespace studentFrom
  6. {
  7.     class Student
  8.     {
  9.         String StudentName;      //字符串的表达学生的名字
  10.         String Professional;     //字符串表达的专业
  11.         String Sex;              // 性别
  12.         int BrithYear;           //出生年
  13.        public Student(String MyName,
  14.                 String MyProf,
  15.                 String MySex,
  16.                 int MyBirthYear
  17.             )
  18.         {
  19.             StudentName = MyName;
  20.             Professional = MyProf;
  21.             Sex = MySex;
  22.             BrithYear = MyBirthYear;
  23.         }
  24.         public String StudentInfo()
  25.         {
  26.             String Info = "";
  27.             Info = "我的专业:" + Professional;
  28.             return Info;
  29.         }
  30.         public void ModifyProf(String NewProf)      //通过公共的方法访问修改内部的数据
  31.         {
  32.             Professional =NewProf;
  33.            
  34.         }

  35.     }
  36. }


图片如下:



阅读(1290) | 评论(0) | 转发(0) |
0

上一篇:C# 加载图片的应用

下一篇:PHP的注意事项

给主人留下些什么吧!~~