diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\261\217\345\271\225\346\210\252\345\233\276 2023-04-10 232131.png" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\261\217\345\271\225\346\210\252\345\233\276 2023-04-10 232131.png" new file mode 100644 index 0000000000000000000000000000000000000000..b0f5d0fff478ce5785b03da918caa41fd4a0834d Binary files /dev/null and "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\261\217\345\271\225\346\210\252\345\233\276 2023-04-10 232131.png" differ diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Library.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Library.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bfdffebf843f5594f1ab9e999899665c4a3dd713 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Library.cs" @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ +//三.定义一个图书类 +//1.定义字段存放图书的编号、书名、价格、出版社、作者信息; +//2.对价格进行赋值限制,小于0价格,赋值为0 +//3.在图书类中定义一个方法输出图书信息; +//4.在主方法实例化对象,赋值并输出 + internal class Library + { + //定义 + int id;//编号 + string name;//书名 + double price;//价格 + string press;//出版社 + string author;//作者信息 + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public double Price + { + get => price; + set + { + if (value < 0) + { + price = 0; + } + else + { + price = value; + } + } + } + public string Press { get => press; set => press = value; } + public string Author { get => author; set => author = value; } + + public Library() + { + + } + + public Library(int id, string name, double price, string press, string author) + { + this.id = id; + this.name = name; + this.price = price; + this.press = press; + this.author = author; + } + + public void Libraryinfo() + { + Console.WriteLine($"编号:{id}"); + Console.WriteLine($"书名:{name}"); + Console.WriteLine($"价格:{price}"); + Console.WriteLine($"出版社:{press}"); + Console.WriteLine($"作者信息:{author}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3b0aa6c0d501b55c8b243459a93b0341aa51da7b --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,40 @@ +using 类; + +namespace 构造 +{ + internal class Program + { + static void Main(string[] args) + { + // 一、定义一个员工类 + //1.定义字段,存放用户的工号、姓名、性别、学历和部门信息; + //2.定义属性封装字段 + //3.定义2个构造函数: + // 一个是无参构造函数,学历默认为专科; + // 一个有参构造函数,根据参数对类的属性进行初始化。 + + Yg yg1 = new Yg(007, "陈qq", '女', "教授", "特工"); + yg1.Yginfo(); + Console.WriteLine("\n"); + Yg yg2 = new Yg(4584, "临春香", '男', "博士后", "秘密"); + yg2.Yginfo(); + + // 二、为之前作业中的学生类、用户类和图书类添加2个构造方法 + //1.一个无参的构造方法 + //2.一个有参的构造方法,根据参数对类的属性进行初始化 + Console.WriteLine("\n"); + User user1= new User(15,"陈qq","123456"); + user1.Userinfo(); + + + Console.WriteLine("\n"); + Student student1 = new Student(45, "小米", '女', 62, "秘密"); + student1.Studentinfo(); + + + Console.WriteLine("\n"); + Library library1 = new Library(66, "安徒生童话", 65.2, "清华北大", "未知"); + library1.Libraryinfo(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Student.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4a93548b1a8019d4a531c2ca981ad9845461f8f1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Student.cs" @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + /** + * 二. 定义一个学生类 +1.定义字段存放学生的学号、姓名、性别、年龄、专业信息; +2.对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; +3.在学生类中定义一个方法输出学生信息。 +4. 在主方法实例化学生对象,赋值并输出 + + */ + internal class Student + { + int id;//学号 + string name;//姓名 + char sex;//性别 + int age;//年龄 + string major;//专业信息 + + //属性 + public int Id { get=>id; set=>id = value; } + public string Name { get=>name;set=>name = value; } + public char Sex { get=>sex;set=>sex = value; } + //(小于0或者大于128岁),该年龄值为0 + public int Age + { + get => age; + set + { + if (value < 0 || value > 128) + { + age = 0; + } + else + { + age = value; + } + } + } + + public string Major { get=>major;set=>major = value; } + + public Student() + { + + } + + public Student(int id, string name, char sex, int age, string major) + { + this.id = id; + this.name = name; + this.sex = sex; + this.age = age; + this.major = major; + } + + public void Studentinfo() + { + Console.WriteLine($"学号:{id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"性别:{sex}"); + Console.WriteLine($"年龄:{age}"); + Console.WriteLine($"专业信息:{major}"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/User.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dddc8261160a4f0476079756e253e1967462eb37 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/User.cs" @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + /** + * 一. 定义一个用户类 +1.定义字段存放用户的账号、用户名和密码; +2.在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息; +3.在用户类中定义一个 登录身份辨认的方法:规则为用户名为“admin”和密码为“123456”时返回“管理员”,否则返回“普通用户”; +4.在主方法中实例化用户类的对象,然后对其账号、用户名和密码赋值 +5.在主方法中用实例化的对象调用方法,输出用户对象的信息和身份(管理员或者普通用户) + + + */ + internal class User + { + int id;//账户 + string name;//用户名 + string password;//密码 + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public string Password + { + get => password; + set + { + if(value.Length>=6 && value.Length <= 10) + { + password = value; + } + else + { + value = "123456"; + } + } + } + public string Ff() + { + if(Name=="admin" && Password == "123456") + { + return "管理员"; + } + else + { + return "普通用户"; + } + } + + //无参 + public User() + { + id= 1; + name= "admin"; + password= "123456"; + } + + //有参 + public User(int id,string name,string password) + { + this.id = id; + this.name = name; + this.password = password; + } + public void Userinfo() + { + Console.WriteLine($"账号:{id}"); + Console.WriteLine($"用户名:{name}"); + Console.WriteLine($"密码:{password}"); + Console.WriteLine($"身份:{Ff()}"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Yg.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Yg.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2407eb623840eb3a4ea95cd19f800ff3c3253834 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/Yg.cs" @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 构造 +{ +// 一、定义一个员工类 +//1.定义字段,存放用户的工号、姓名、性别、学历和部门信息; +//2.定义属性封装字段 +//3.定义2个构造函数: +// 一个是无参构造函数,学历默认为专科; +// 一个有参构造函数,根据参数对类的属性进行初始化。 + internal class Yg + { + int id;//工号 + string name;//姓名 + char sex;//性别 + string education;//学历 + string department;//部门信息 + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public char Sex { get => sex; set => sex = value; } + public string Education { get => education; set => education = value; } + public string Department { get => department; set => department = value; } + + //一个是无参构造函数,学历默认为专科; + public Yg() + { + education = "专科"; + + } + //一个有参构造函数,根据参数对类的属性进行初始化。 + public Yg(int id,string name,char sex,string education,string deparment) + { + this.id = id; + this.name = name; + this.sex = sex; + this.education = education; + this.department = deparment; + } + public void Yginfo() + { + + Console.WriteLine($"工号:{id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"性别:{sex}"); + Console.WriteLine($"学历:{education}"); + Console.WriteLine($"部门:{department}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a39ab9d056725b298b5a85e4d67f41a55a3488c0 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.cs" @@ -0,0 +1,302 @@ +using System.Globalization; + +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + /*1.求圆的面积 + 要求用户输入半径的值,打印出以此值为半径的圆的面积 + 求圆的面积的公式:πr²。 + 圆周率π定义成常量取3.14。 + r由用户输入并存入一个变量中,此变量用double比较合适,因为用户可能会输入小数。*/ + Console.WriteLine(); + Console.WriteLine("第1题"); + double r, S; + Console.WriteLine("请输入圆的半径"); + r=double.Parse(Console.ReadLine()); + double pai = 3.14; + S = r * r * pai; + Console.WriteLine("圆的面积=" + S); + + /*2.编写一个程序,请用户输入一个四位整数, + * 将用户输入的四位数的千位、百位、十位和个位分别显示出来, + * 如5632,则显示“用户输入的千位为5,百位为6,十位为3,个位为2”*/ + Console.WriteLine(); + Console.WriteLine("第2题"); + Console.WriteLine("请输入一个四位整数"); + int num=int.Parse(Console.ReadLine()); + int a, b, c, d; + a = num % 10; + b = (num % 100) / 10; + c = (num / 100) % 10; + d = num /1000; + Console.WriteLine("个位是" + a); + Console.WriteLine("十位是" + b); + Console.WriteLine("百位是" + c); + Console.WriteLine("千位是"+d); + + /*3.用户输入三个数,找出最大的数,打印输出。*/ + Console.WriteLine(); + Console.WriteLine("第3题"); + Console.WriteLine("请输入第一个数"); + double a1=double.Parse(Console.ReadLine()); + Console.WriteLine("请输入第二个数"); + double b1=double.Parse(Console.ReadLine()); + Console.WriteLine("请输入第三个数"); + double c1=double.Parse(Console.ReadLine()); + if(a1>b1) + { + Console.WriteLine("最大的数是="+a1); + } + else if (b1 > c1) + { + Console.WriteLine("最大的数是=" + b1); + } + else if(c1 > a1) { + Console.WriteLine("最大的数是=" + c1); + } + /*4.接受用户输入一个数n,求这个数的阶乘; + * 5! = 5 * 4 * 3 * 2 * 1;*/ + Console.WriteLine(); + Console.WriteLine("第4题"); + Console.WriteLine("输入一个数"); + int num1=int.Parse(Console.ReadLine()); + for (int i=num1-1;i>1; i--) + { + num1 *= i; + } + Console.WriteLine("这个数的阶乘=" + num1); + + /*5.接受用户输入的一个数n,求n到1所有数的阶乘和; + * n! + (n - 1!) + (n - 2)! +……+1!*/ + Console.WriteLine(); + Console.WriteLine("第5题"); + Console.WriteLine("输入一个数:"); + int num2=int.Parse(Console.ReadLine()); + int a2=1; + int sum = 0; + for(int n=1; n <= num2; n++) + { + a2 *= n; + sum+=a2; + } + Console.WriteLine("阶乘和是="+sum); + + /*6.根据用户输入的菱形边长,打印菱形;如边长为3,行数为5;*/ + Console.WriteLine(); + Console.WriteLine("第6题"); + Console.WriteLine("打印菱形"); + //上半部分 + for(int h = 1; h <= 3; h++) + { + for (int L = 1; L<= 3 - h; L++) + { + Console.Write(" "); + } + for(int k = 1; k <= 2 * h - 1; k++) + { + Console.Write("*"); + } + Console.WriteLine(); + } + //下半部分 + for(int h = 2; h >= 1; h--) + { + for(int L = 1; L <= 3 - h; L++) + { + Console.Write(" "); + }for(int k = 1; k <= 2 * h - 1; k++) + { + Console.Write("*"); + } + Console.WriteLine(); + } + + /*7.用循环打印九九乘法表(用二维数组保存字符串后再打印)*/ + Console.WriteLine(); + Console.WriteLine("第7题"); + for (int j = 1; j < 10; j++) + { + for(int j1 = 1; j1 <=j; j1++) + { + Console.Write(j+"*"+j1+"="+j*j1+"\t"); + + } + Console.WriteLine(); + } + + /*8.输入一行字符串,分别统计出其中英文字母、数字、空格的个数。*/ + Console.WriteLine(); + Console.WriteLine("第8题"); + Console.WriteLine("请输入一行字符串"); + int zm = 0;//字母数量 + int number= 0;//数字数量 + int kg = 0;//空格数量 + int qt = 0;//其他数量 + string str = ""; + str=Console.ReadLine(); + char[] d1 = str.ToCharArray(); + foreach(char c2 in d1) + { + if (c2 >= 'a' && c2<= 'z' || c2 >= 'A' && c2 <= 'Z') + zm++; + else if (c2 >= '0' && c2 <= '9') + num++; + else if (c2 == ' ') + kg++; + else + qt++; + } + Console.WriteLine("字母有"+zm+"个,数字有"+num+"个,空格要"+kg+"个,其他的有"+qt+"个"); + + /*9.在 Main 方法中创建一个 double 类型的数组,并在该数组中存入 5 名学生的考试成绩,计算总成绩和平均成绩。(要求使用foreach语句实现该功能)*/ + Console.WriteLine(); + Console.WriteLine("第19题"); + double[] scores = { 95, 96, 94, 93, 92 }; + double sum1 = 0; + double avg = 0; + foreach (double score in scores) + { + sum1 += score; + } + avg = sum1 / scores.Length; + Console.WriteLine("总成绩"+sum1); + Console.WriteLine("平均成绩"+avg); + + /*10.定义一个方法,实现一维数组的排序功能,从大到小排序。(不要用Array类的方法)*/ + Console.WriteLine(); + Console.WriteLine("第10题"); + int[] number2 = { 10, 20, 30, 40, 50 }; + for (int e = 0; e < number2.Length; e++) + { + for (int f = 0; f < number2.Length - e - 1; f++) + { + if (number2[f] < number2[f + 1]) + { + int temp = number2[f]; + number2[f] = number2[f + 1]; + number2[f + 1] = temp; + } + } + } + Console.WriteLine("从大到小排序"); + foreach (int g in number2) + { + Console.Write(g + "\t"); + } + Console.WriteLine(); + /*11.实现查找数组元素索引的功能。定义一个数组,然后控制台输入要查找的元素,返回输入值在数组中最后一次出现的位置。若是找不到,请打印找不到。(不要用Array类的方法)*/ + Console.WriteLine(); + Console.WriteLine("第11题"); + int[] arr1 = new int[] { 78,56,44,23,22}; + Console.WriteLine("请输入要查找的元素:"); + int cz = Convert.ToInt32(Console.ReadLine()); + int index = -1; + for (int i = 0; i < arr1.Length; i++) + { + if (arr1[i] == cz) + { + index = i; + } + } + if (index == -1) + { + Console.WriteLine("找不到该元素"); + } + else + { + Console.WriteLine("该元素最后一次出现的位置是:" + index); + } + + /*12.在 Main 方法中创建一个字符串类型的数组,并存入 5 个值,然后将数组中下标是偶数的元素输出。*/ + Console.WriteLine(); + Console.WriteLine("第12题"); + int[] arr = new int[5] { 12, 22, 32, 42,52 }; + for (int i = 0; i <= arr.Length; i++) + { + if (arr[i] % 2 == 0) + { + Console.Write("偶数为" + arr[i]); + } + else + { + Console.WriteLine("奇数为" + arr[i]); + } + + } + + /*13.用户输入正方形边长,用* 打印出空心正方形。 + 如:用户输入5,则输出如下图形。*/ + Console.WriteLine(); + Console.WriteLine("第13题"); + Console.WriteLine( "输入边长"); + int z=Convert.ToInt32(Console.ReadLine()); + for (int i = 0; i < z; i++) + { + for (int j = 0; j < z; j++) + { + if (i == 0 || j == 0 || i == z - 1 || j == z - 1) + { + Console.Write("*"); + } + else + Console.Write(" "); + } + Console.Write("\n"); + } + + /*14.用户输入正方形边长,用* 打印出实心正方形。 + 如:用户输入5,则输出如下图形。*/ + Console.WriteLine(); + Console.WriteLine("第14题"); + Console.WriteLine("请输入正方形边长"); + int z1= Convert.ToInt32(Console.ReadLine()); + for (int i = 0; i < z1; i++) + { + for (int j = 0; j < z1; j++) + { + Console.Write("*"); + } + Console.Write("\n"); + } + + + /*15.用二维数组存放数据,实现杨辉三角形的打印;*/ + int[][] yang = new int[10][]; + for (int i = 0; i < 10; i++) + { + yang[i] = new int[i + 1]; + } + for (int i = 0; i < yang.Length; i++) + { + for (int j = 0; j < yang[i].Length; j++) + { + if (j == 0 || j == i) + { + yang[i][j] = 1; + } + else + { + yang[i][j] = yang[i - 1][j - 1] + yang[i - 1][j]; + } + } + } + for (int i = 0; i < yang.Length; i++) + { + for (int j = 0; j < yang[i].Length; j++) + { + Console.Write(yang[i][j] + " "); + } + } + Console.WriteLine(); + + + + + + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Accountmanager.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Accountmanager.cs" new file mode 100644 index 0000000000000000000000000000000000000000..82193fea2a9a5a26230b0be7777feb6675103d6f --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Accountmanager.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Accountmanager:Employee + { + double wage; + public double Wage + { + get;set; + } + public Accountmanager(string name, double nianxian, double year,double fenhong):base( name, nianxian, year,fenhong ) + { + Wage = wage; + } + + public void Accountmanagerinfo() + { + + base.Employeeinfo(); + Console.WriteLine($"年薪是{Wage}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Employee.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Employee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dbf4f146d1dc5cefa2bedfab05a23f6197f26e88 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Employee.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Employee + { + string name;//姓名 + double nianxian;//工作年限 + double year;//月薪 + double fenhong;//分红 + + public string Name { get => name; set => name = value; } + public double Nianxian { get => nianxian; set => nianxian = value; } + public double Year { get => year; set => year = value; } + public double Fenhong { get=>fenhong ; set => fenhong = value; } + + public Employee() { } + public Employee(string name,double nianxian,double year,double fenhong) + { + this.Name = name; + this.Nianxian = nianxian; + this.Year = year; + this.Fenhong = fenhong; + + } + + public void Employeeinfo() + { + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"工作年限:{Nianxian}"); + Console.WriteLine($"月薪:{Year}"); + Console.WriteLine($"基础分红:{Fenhong}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Groupleader.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Groupleader.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3f8d8ca9b41a09eee43e7899bb32d52fd09db554 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Groupleader.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace 员工类 +{ + internal class Groupleader:Employee + { + double wage; + public double Wage { get; set; } + + public Groupleader() + { + this.wage = wage; + } + public void Groupleaderinfo() + { + + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"工作年限:{Nianxian}"); + Console.WriteLine($"月薪:{Year}"); + Console.WriteLine($"年薪{ Wage}"); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Manager.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Manager.cs" new file mode 100644 index 0000000000000000000000000000000000000000..432518ba812ec4c56332bc7f3cbf28fc7943d4c0 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Manager.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Manager:Employee + { + double wage; + public double Wage + { + get;set; + } + public Manager() + { + this .Wage = Wage; + } + public void Managerinfo() + { + + base.Employeeinfo(); + Console.WriteLine( $"年薪{Wage}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d0be2a20814d1df6575563b92d05a21f5ff20d87 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" @@ -0,0 +1,31 @@ +namespace 员工类 +{ + internal class Program + { + static void Main(string[] args) + { + Groupleader zz=new Groupleader(); + zz.Name = "陈qq"; + zz.Year = 5000; + zz.Nianxian = 2; + zz.Wage=zz.Year+1000*zz.Nianxian; + zz.Groupleaderinfo(); + + Console.WriteLine( "\n"); + + Manager jl=new Manager(); + jl.Name = "lsm"; + jl.Year = 5000; + jl.Nianxian = 3; + jl.Fenhong = 1000; + jl.Wage=jl.Year+1000*jl.Nianxian*jl.Fenhong; + jl.Managerinfo(); + + Console.WriteLine("\n"); + Accountmanager khjl=new Accountmanager("林春想",2.5,2000,1000); + khjl.Wage=khjl.Year+1000*khjl.Nianxian*khjl.Fenhong; + khjl.Fenhong = 1000 * 3; + khjl.Accountmanagerinfo(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Circle.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Circle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6691543078eab7a02752d5ba60ca8e105433f7ea --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Circle.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 图形类 +{ + internal class Circle:Together + { + double r; + double pai; + + public double R { get; set; } + public double Pai { get; set; } + + public Circle() + { + this .r = r; + this .pai = pai; + + } + + public void Circleinfo() + { + Console.WriteLine($"圆的半径{R}"); + base.Togetherinfo(); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..afecf294e2e58e121f3376ff60a85073934ac151 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Program.cs" @@ -0,0 +1,38 @@ +namespace 图形类 +{ + internal class Program + { + static void Main(string[] args) + { + Circle yuan = new Circle(); + yuan.R = 3; + yuan.Pai = 3.14; + yuan.Mian = yuan.R * yuan.R * yuan.Pai; + yuan.Zhou = 2 * yuan.Pai * yuan.R; + yuan.Circleinfo(); + + Console.WriteLine("\n"); + + Triangle sjx=new Triangle(); + sjx.A = 1; + sjx.B = 1; + sjx.C = 3; + sjx.Gao = 0.5; + sjx.Mian = sjx.C * sjx.Gao / 2; + sjx.Zhou=sjx.A+sjx.B+sjx.C; + sjx.Triangleinfo(); + Console.WriteLine("\n"); + + Quadrilateral sbx = new Quadrilateral(); + sbx.A = 1; + sbx.B = 1; + sbx.C = 1; + sbx.D = 1; + sbx.Mian=(sbx.A+sbx.B+sbx.C+sbx.D)/2; + sbx.Zhou = sbx.A + sbx.B + sbx.C + sbx.D; + sbx.Quadrilateralinfo(); + + } + + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Quadrilateral.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Quadrilateral.cs" new file mode 100644 index 0000000000000000000000000000000000000000..49ddb54441ac235d52efe017fe38853ee7bdf8b1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Quadrilateral.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 图形类 +{ + internal class Quadrilateral : Together + { + double a; + double b; + double c; + double d; + + + public double A { get => a; set => a = value; } + public double B { get => b; set => b = value; } + public double C { get => c; set => c = value; } + public double D { get => d; set => d = value; } + + public Quadrilateral() + { + A = a; + B = b; + C = c; + D = d; + + } + + public void Quadrilateralinfo() + { + Console.WriteLine($"四边形的边长是:{A},{B},{C},{D}"); + base.Togetherinfo(); + } + } + + } diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Together.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Together.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2b5939657188b6fa10b870c1e6536231d276fcca --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Together.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 图形类 +{ + internal class Together + { + double zhou; + double mian; + + public double Zhou { get => zhou; set => zhou = value; } + public double Mian { get => mian; set => mian = value; } + + public Together () { } + public Together (double Zhou, double Mian) + { + this.Zhou = Zhou; + this.Mian = Mian; + } + public void Togetherinfo() + { + Console.WriteLine($"周长是{Zhou}"); + Console.WriteLine($"面积是{Mian}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Triangle.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Triangle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..51e802c7a67e3dc312be2adc65ffb6a358804e67 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\276\345\275\242/Triangle.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 图形类 +{ + internal class Triangle:Together + { + double a; + double b; + double c; + double gao; + + public double A { get => a; set => a = value; } + public double B { get => b; set => b = value; } + public double C { get => c; set => c = value; } + public double Gao { get => gao; set => gao = value; } + + public Triangle( ) + { + A = a; + B = b; + C = c; + Gao = gao; + + } + + public void Triangleinfo() + { + Console.WriteLine($"三角形的边长是:{A},{B},{C}"); + Console.WriteLine($"高是{Gao}"); + base.Togetherinfo(); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..89ea58cd54bff37d7af8fe1ac9cc4c109e25ea4f --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Program.cs" @@ -0,0 +1,18 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Undergraduate bk1= new Undergraduate("刘文",22,"本科","网络技术"); + bk1.Undergraduateinfo(); + + Console.WriteLine("\n"); + Specialty zk1 = new Specialty("王蕾", 17, "专科", "Java"); + zk1.Specialtyinfo(); + + + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Specialty.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Specialty.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8baddc2ee191e58227d5df4c2e831ec71af2f618 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Specialty.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Specialty:Student + //专科类 + { + string sprc; + public string Sprc { get=>sprc; set=>sprc=value; } + + public Specialty() { } + + public Specialty(string name, int age, string degree,string sprc) :base (name,age,degree) + { + this.Name = name; + this.Age = age; + this.Degree = degree; + this.Sprc = sprc; + } + public void Specialtyinfo() + { + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"年龄:{Age}"); + Console.WriteLine($"学位:{Degree}"); + Console.WriteLine($"专业:{Sprc}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Student.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a08b63dc2768a4bd6b0785ba69d3f721683bf7e1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Student.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Student + { + string name; + int age; + string degree; + + public string Name { get => name; set => name = value; } + public int Age { get => age; set => age = value; } + public string Degree { get => degree; set => degree = value; } + + public Student() { } + public Student(string name,int age,string degree) + { + this.name = name; + this.age = age; + this.degree = degree; + } + + public void Studentinfo() + { + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"年龄:{Age}"); + Console.WriteLine($"学位:{Degree }"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Undergraduate.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Undergraduate.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dc9e613d092b70a024c3623927767aba3b1b8bc1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\255\246\347\224\237/Undergraduate.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Undergraduate:Student + //本科类 + { + string drec; + + public string Drec { get => drec; set => drec = value; } + + public Undergraduate() { } + public Undergraduate(string name, int age, string degree, string drec) : base(name, age, degree) + { + this.Name = name; + this.Age = age; + this.Degree = degree; + this.Drec = drec; + + } + public void Undergraduateinfo() + { + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"年龄:{Age}"); + Console.WriteLine($"学位:{Degree}"); + Console.WriteLine($"研究方向:{Drec}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Car.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Car.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3f6bfc13f9fe56a9925f4352f75dc77d1c97ac19 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Car.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 汽车 +{ + internal class Car:Vehicle + { + int loader;//有载数量 + + public int Loader { get => loader; set => loader = value; } + public Car(string brand, int wheels, string weight, int loader) : base(brand, wheels, weight) + { + this.loader = loader; + } + + public void Caeinfo() + { + base.Vehicleinfo(); + Console.WriteLine($"有载重量:{Loader}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7aa816a4a073d9cd6b7e08911f1c489a5110139f --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Program.cs" @@ -0,0 +1,16 @@ +namespace 汽车 +{ + internal class Program + { + static void Main(string[] args) + { + Car xc=new Car("奔驰",4,"2590磅",5); + xc.Caeinfo(); + + Console.WriteLine("\n"); + Truck kc = new Truck("本田",4,"1530kg","10000kg"); + kc.Truckinfo(); + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Truck.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Truck.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a074977452d34545907e3324e803acb10705711 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Truck.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 汽车 +{ + internal class Truck:Vehicle + { + string payload;//有载重量 + + public string Payload { get => payload; set => payload = value; } + + public Truck(string brand, int wheels, string weight,string Payload):base(brand,wheels,weight) + { + this.Payload = Payload; + } + + public void Truckinfo() + { + base.Vehicleinfo(); + Console.WriteLine($"有载重量: {Payload}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Vehicle.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Vehicle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ceaa9048ef3cf964b926cede82c1d8ef9db90663 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\346\261\275\350\275\246/Vehicle.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 汽车 +{ + internal class Vehicle + { + string brand;//汽车品牌 + int wheels;//车轮个数 + string weight;//车重 + + public string Brand { get => brand; set => brand = value; } + public int Wheels { get => wheels; set => wheels = value; } + public string Weight { get => weight; set => weight = value; } + + public Vehicle() { } + public Vehicle(string brand,int wheels,string weight) + { + this .brand = brand; + this .wheels = wheels; + this .weight = weight; + } + public void Vehicleinfo() + { + Console.WriteLine($"汽车品牌:{Brand}"); + Console.WriteLine($"车轮个数:{Wheels}"); + Console.WriteLine($"车重:{Weight}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Dustman.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Dustman.cs" new file mode 100644 index 0000000000000000000000000000000000000000..39012141a36195e90febc95dc100d9f4fa2bd4d8 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Dustman.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Guyuan +{ + //清洁工 + internal class Dustman:Guyuan + { + double dwage; + public double Dwage { get => dwage; set => dwage = value; } + + public Dustman (string name, string address, string birthday, double dwage) : base(name, address, birthday) + { + dwage = dwage; + } + public void Dustmaninfo() + { + decimal Dwaye = 3000; + base.Guyuaninfo(); + Console.WriteLine($"{Name}的工资为{Dwaye}"); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Guyuan.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Guyuan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..71170ec03e804b3d24e23e4a7869bba794853b99 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Guyuan.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Guyuan +{ + internal class Guyuan + { + string name;//姓名 + string address;//地址 + string birthday;//出生日期 + + public string Name { get => name; set => name = value; } + public string Address { get => address; set => address = value; } + public string Birthday { get => birthday; set => birthday = value; } + + public Guyuan() { } + + public Guyuan(string name,string address,string birthday) + { + this.name = name; + this .address = address; + this .birthday = birthday; + } + + public void Guyuaninfo() + { + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"地址:{address}"); + Console.WriteLine($"出生日期:{birthday}"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f13d45c5a161fc3ee2e98dac57af10c8b8378bd5 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Program.cs" @@ -0,0 +1,24 @@ +namespace Guyuan +{ + internal class Program + { + static void Main(string[] args) + { + Programmer programmer = new Programmer("陈qq","贵州遵义","2023.01.01",2000); + programmer.Wageinfo(8579,0.25m); + + Console.WriteLine("\n"); + + Secretary ms = new Secretary("林春香", "福建莆田", "2023.02.01", 3000); + ms.Secretaryinfo(); + + Console.WriteLine("\n"); + Dustman qjg = new Dustman("不子明", "福建龙岩", "1650.02.15", 3000); + qjg.Dustmaninfo (); + + Console.WriteLine("\n"); + Topmanagerment topmanagerment=new Topmanagerment ("付秀秀","安徽亳州","2003.09.12",5000); + topmanagerment.Topinfo (20, 0.25m); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Programmer.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Programmer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..48e689f8a3eae2f19c397c8fcde7e56afb907884 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Programmer.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Guyuan +{ + internal class Programmer:Guyuan + //程序员 + { + double wage; + + + + public double Wage { get => wage; set => wage = value; } + public Programmer() { } + + public Programmer(string name, string address, string birthday,double wage):base (name,address,birthday) + { + } + public void Wageinfo(decimal sale,decimal ratio) + { + base.Guyuaninfo(); + decimal Wage = 8000 + sale * ratio; + Console.WriteLine($"{Name}的工资为{Wage}"); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Secretary.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Secretary.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a3f830da36407e559d462fa27dcdcd76a11c325a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Secretary.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Guyuan +{//秘书 + internal class Secretary:Guyuan + { + double swage; + public double Swage { get=>swage;set=>swage=value ; } + + public Secretary(string name, string address, string birthday,double swage):base(name ,address ,birthday ) + { + } + public void Secretaryinfo() + { + + base.Guyuaninfo(); + decimal Swaye = 3000; + Console.WriteLine($"{Name}的工资为{Swaye}"); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Topmanagerment.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Topmanagerment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..51d1ef30673526b085e96aa24a0c6133222721ac --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\233\207\345\221\230/Topmanagerment.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Guyuan +{ + //高级主管 + internal class Topmanagerment:Guyuan + { + double twage; + public double Twage { get => twage; set => twage = value; } + + public Topmanagerment (string name, string address, string birthday, double twage) : base(name, address, birthday) + { + this .twage = twage; + } + public void Topinfo(decimal sale, decimal retio) + { + decimal Twaye = 3000 + sale * retio; + base.Guyuaninfo(); + Console.WriteLine($"{Name}的工资为{Twaye}"); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2321.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2321.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d5dba44f95304ef1cf4eb7076dbf2f6bb50f5749 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2321.cs" @@ -0,0 +1,121 @@ +namespace ConsoleApp2 +{ + internal class Program + { + //1. + + + static void Main(string[] args) + { + Console.WriteLine("善学如春起之苗"); + Console.WriteLine("不见其增,日有所长"); + Console.WriteLine("假学如磨刀之石"); + Console.WriteLine("不见其损,年有所亏"); + Console.WriteLine("加油吧!少年"); + Console.WriteLine("J\nA\nV\nA\n!\n"); + } + } + + //2. + internal class Homework3 + { + static void Main(string[] args) + { + Console.WriteLine("true"); + Console.WriteLine("false"); + } + } + + //3. + internal class Homework4 + { + static void Main(string[] args) + { + sbyte num1 = -128; + byte num2 = 127; + Console.WriteLine(num1); + Console.WriteLine(num2); + + short num3 = -32768; + short num4 = 32767; + Console.WriteLine(num3); + Console.WriteLine(num4); + + int num5 = -2147483648; + int num6 = 2147483647; + Console.WriteLine(num5); + Console.WriteLine(num6); + + long num7 = -2147483649; + long num8 = 2147483648; + Console.WriteLine(num7); + Console.WriteLine(num8); + } + } + + //4. + internal class Homwork5 + { + static void Main(string[] ags) + { + float num9 = -3.14F; + float num10 = 3.14F; + Console.WriteLine(num9); + Console.WriteLine(num10); + double num11 = -3.4; + double num12 = 3.4; + Console.WriteLine(num11); + Console.WriteLine(num12); + } + } + + //5. + internal class Homework6 + { + static void Main(string[] avgs) + { + int a = 10; + int b = 20; + int temp = a; + a = b; + b = temp; + Console.WriteLine("a的值是"+a); + Console.WriteLine("b的值是"+b); + } + } + + internal class Homework7 + { + static void Main(string[] args) + { + int x = 100; + int y = 200; + int add = x + y; + int sub = x - y; + int mul = x * y; + int div = x / y; + Console.WriteLine("x,y的和为:"+add); + Console.WriteLine("x,y的差为:"+sub); + Console.WriteLine("x,y的积为:"+mul); + Console.WriteLine("x,y的商为:"+div); + } + } + + //6. + internal class Homework8 + { + static void Main(string[] args) + { + double x = 100.8; + double y = 20.6; + double add = x + y; + double sub = x - y; + double mul = x * y; + double div = x / y; + Console.WriteLine("x,y的和为:"+add); + Console.WriteLine("x,y的差为:"+sub); + Console.WriteLine("x,y的积为:"+mul); + Console.WriteLine("x,y的商为:"+div); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2322.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2322.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d11f33cbd1724a60e89c227bad0918951988a839 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\2322.cs" @@ -0,0 +1,266 @@ +namespace 基础2 +{ + internal class Program + { + static void Main(string[] args) + { + /*1、判断一个字符数据是否是数字字符 + 分析: + 1、需要判断一个字符是否是数字字符,首先需要提供一个字符数据 + 2、字符是否为数字字符: 数字字符的范围 0 - 9 之间都属于数字字符,因此提供的字符只要大于或等于字符0,并且还要下于或等于字符9即可。 + 3、判断完成之后,打印判断的结果。*/ + Console.WriteLine("第1题------"); + Console.WriteLine("输入一个字符是否是数字字符"); + char a = Convert.ToChar(Console.ReadLine()); + if(a>='0' && a <= '9') + { + Console.WriteLine("是数字字符"); + } + else + { + Console.WriteLine("不是数字字符"); + } + + + /*2、判断一个字符数据是否是字母字符 + 分析: + + ​ 1、需要判断一个字符是否是字母字符,首先需要提供一个字符数据 + + ​ 2、字符是否为字母字符: 数字字符的范围 a -z 或者 A -Z 之间都属于字母字符,因此提供的字符只要大于或等于a,并且还要下于或等于z 或者 大于或等于A,并且还要下于或等于Z + + ​ 3、判断完成之后,打印判断的结果。*/ + Console.WriteLine(); + Console.WriteLine("第2题------"); + Console.WriteLine("输入一个字符是否字母字符"); + char b= Convert.ToChar(Console.ReadLine()); + if (b>='a' && b<='z') + { + Console.WriteLine("是小写字母"); + }else if(b>='A' && b <= 'Z') + { + Console.WriteLine("是大写字母"); + } + else + { + Console.WriteLine("不是字母字符"); + } + + + /**3、判断指定的年份是否为闰年,请使用键盘录入** +分析: + +​ 1、闰年的判断公式为:能被4整除,但是不能被100整除 或者 能被400整除 + +​ 2、首先需要提供一个需要判断的年份,判断完成之后,打印判断的结果。*/ + Console.WriteLine(); + Console.WriteLine("第3题------"); + Console.WriteLine("请输入年份"); + int year=int.Parse(Console.ReadLine()); + if(year%4==0 && year%100!=0 || year%400==0 ) + { + Console.WriteLine($"{year}是闰年"); + } + else + { + Console.WriteLine($"{year}是平年"); + } + + + /**4、判断一个数字是否为水仙花数,请使用键盘录入** + +水仙花是指3位数字,表示的是每位上的数字的3次幂相加之后的和值和原数相等,则为水仙花数, + + **分析:** + +​ 如:153---> 1×1×*1 + 5 *×5×*5 + 3×*3×3 = 153; 就是水仙花数 + +​ 1、首先需要提供一个需要判断的3位数字,因此需要一个数值 + +​ 2、判断的过程 + +​ a) 将3位数字的每一位上的数字拆分下来 + +​ b) 计算每位数字的3次幂之和 + +​ C) 用和值 和 原来的数字进行比较 + +​ D) 打印判断的比较结果即可*/ + Console.WriteLine(); + Console.WriteLine("第4题------"); + Console.WriteLine("请输入一个数字是否是水仙花数"); + int c, d, e; + int num=int.Parse(Console.ReadLine()); + c = num / 100; + d = num /10% 10; + e = num % 10; + if (num == c * c * c + d * d * d + e * e * e) + { + Console.WriteLine("是水仙花"); + } + else + { + Console.WriteLine("不是水仙花"); + } + + + /* *5、判断一个5位数字是否为回文数,使用键盘录入** + + 五位数的回文数是指最高位和最低位相等,次高位和次低位相等。如:12321 23732 56665 + * *分析:** + + ​ 1、首先需要提供一个需要判断的5位数字,因此需要一个数值 + + ​ 2、判断的过程 + + ​ a) 将5位数字的万、千、十、个位数拆分出来 + + ​ b) 判断比较万位和个位 、 千位和十位是否相等 + + ​ 3、判断完成之后,打印判断的结果。*/ + Console.WriteLine(); + Console.WriteLine("第5题------"); + Console.WriteLine("输入一个五位数字"); + int num1=int.Parse(Console.ReadLine()); + int wan,qian,bai,shi,ge; + wan = num1 / 10000; + qian = num1 / 1000 % 10; + bai = num1 / 100 % 10; + shi=num1 / 10% 10; + ge = num1 %10; + if (wan == ge && qian==shi) + { + Console.WriteLine(num1 + "是回文数"); + } + else + { + Console.WriteLine(num1+"不是回文数"); + } + + + + /*知识点:运算符 + + ## 题目1(训练) + + 身高是具有遗传性的,子女的身高和父母的身高有一定的关系。假定,父母和子女的身高遗传关系如下: + + ​ 儿子身高(厘米)=(父亲身高+母亲身高) ×1.08÷2 + + ​ 女儿身高(厘米)=(父亲身高×0.923+母亲身高) ÷2 + + 现有父亲身高177CM,母亲身高165CM。求子女身高分别预计为多少? + + ### 训练提示 + + 1.已知的父母身高如何用代码体现? + + 2.题目中的公式如何转化为代码? + + ### 解题方案 + + 1.使用变量的定义和算术运算符完成本题 + + ### 操作步骤 + + 1.定义小数变量代表父亲身高 + + 2.定义小数变量代表母亲身高 + + 3.通过儿子身高计算方式计算儿子身高 + + 4.通过女儿身高计算方式计算女人身高*/ + Console.WriteLine(); + Console.WriteLine("第6题------"); + Console.WriteLine("请输入爸爸的身高:"); + double father=double.Parse(Console.ReadLine()); + Console.WriteLine("请输入妈妈的身高:"); + double mother=double.Parse(Console.ReadLine()); + double son, daughter; + son = (father + mother) * 1.08 / 2; + Console.WriteLine("儿子的身高"+son); + daughter = (father * 0.923 + mother) / 2; + Console.WriteLine("女儿的身高"+daughter); + + + /* 题目2(训练) + + 红茶妹妹有21元钱,她攒了几天钱之后自己的钱比原来的两倍还多三块。绿茶妹妹有24元钱,她攒了几天钱之后自己的钱正好是原来的两倍。那么红茶和绿茶现在的钱一样多,请问对么? + + ### 训练提示 + + 1.用什么知识点来计算她们现在的钱有多少? + 2.如何对比两个人的钱数? + + ### 解题方案 + + 1.使用赋值运算符和算术运算符计算各自的钱,使用比较运算符对比大小 + + ### 操作步骤 + + 1.定义红茶妹妹原来的钱为整数变量 + 2.定义绿茶妹妹原来的钱为整数变量 + 3.使用赋值运算符和算术运算符计算其现有的钱 + 4.使用比较运算符对数值做出比较*/ + Console.WriteLine(); + Console.WriteLine("第7题------"); + int red, green, red1,green1; + red = 21; + green = 24; + red1 = 21 * 2 + 3; + green1 = 24 * 2; + if (red1 == green1) + { + Console.WriteLine("是对滴"); + } + else + { + Console.WriteLine("是错的"); + } + + /*题目3(综合) + + 某小伙想定一份外卖,商家的优惠方式如下: + 鱼香肉丝单点24元,油炸花生米单点8元,米饭单点3元。订单满30元8折优惠。 + 鱼香肉丝优惠价16元,但是优惠价和折扣不能同时使用。 + 那么这个小伙要点这三样东西,最少要花多少钱? + + ### 训练提示 + + 1.有两种购买方式,一种是不使用优惠价,另一种是使用优惠价。分别计算花费后,对两种方式的花费作对比。 + + ### 解题方案 + + 1.使用算术运算符、赋值运算符和三元运算符联合完成本题 + + ### 操作步骤 + + 1.使用算术运算符求出不使用优惠时的总价 + 2.使用三元运算符判断总价是否满足打折条件,并求出折后总价 + 3.使用算术运算符求出使用优惠价时的总价 + 4.使用三元运算符判断最终更合算的购买方式和花费*/ + Console.WriteLine(); + Console.WriteLine("第8题------"); + int yu, sheng, mi,yuy; + yu = 24; + sheng = 8; + mi = 3; + yuy = 16; + double one = (yu + sheng + mi)*0.8; + double two = yuy + sheng + mi; + if (one > two) + { + Console.WriteLine( "要花"+two+"元"); + } + else + { + Console.WriteLine("要花"+one+"元"); + } + + + + + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Book.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Book.cs" new file mode 100644 index 0000000000000000000000000000000000000000..60b722942f3b0e2821ba88a7e03cc7d1085ac214 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Book.cs" @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + public class Book + { + public int id;//编号 + public string name;//书名 + public double price;//价格 + public string publisher;//出版社 + public string author;//作者 + + //设置属性 + //编号 + public int Id + { + get + { + return id; + } + set + { + id = value; + } + } + //书名 + public string Name + { + get + { + return name; + } + set { name = value; } + } + //价格 + public double Price + { + get { return price; } + set + { + if (price < 0) + { + price = 0; + }else + { price = value; } + } + } + //出版社 + public string Publisher + { + get { return publisher; } + set { publisher = value; } + } + //作者 + public string Author + { + get { return author; } + set { author = value; } + } + //控制台输出 + public void BookIndo() + { + Console.WriteLine($"学号:{this.id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"价格:{price}"); + Console.WriteLine($"出版社:{publisher}"); + Console.WriteLine($"作者:{author}"); + } + } + + +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Enemy.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Enemy.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ea22565bd67a10fc81adb7ab5b6fe24053af2c6e --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Enemy.cs" @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + internal class Enemy + { + // 四.定义一个敌人类 + //1. 定义可以存放敌人的血量、攻击力和魔法值字段; + //2.要求敌人的血量、攻击力和魔法值都只能设置为大于等于0的值;如果小于0则将字段值设置为0 + //3.在类中定义方法代表敌人具有攻击和逃跑的行为 + //4.在主方法中实例化2个敌人对象,为属性赋值,并输出对象的属性值; + //5.使用一个对象调用攻击方法,使用一个对象调用逃跑方法 + string name;//姓名 + double blood;//血量 + double aggressivity;//攻击力 + double magic;//魔法值 + public string Name { get => name; set => name = value; } + public double Blood + { + get => blood; + set + { + if (value >= 0) + { + blood = value; + } + else + { + blood = 0; + } + + } + } + public double Aggressivity + { + get => aggressivity; + set + { + if (value >= 0) + { + aggressivity = value; + } + else + { + aggressivity = 0; + } + + } + } + + public double Magic + { + get => magic; + set + { + if (value >= 0) + { + magic = value; + } + else + { + magic = 0; + } + + } + } + public void Enemyinfo() + { + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"血量是:{blood}"); + Console.WriteLine($"攻击力是:{aggressivity}"); + Console.WriteLine($"魔法值是:{magic}"); + Console.WriteLine($"{name}攻击"); + Console.WriteLine($"{name}逃跑"); + } + public string Gj { get => Gj; set => Gj = value; } + public string Run { get => Run; set => Run = value; } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Hero.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a80de5639908caf4ce041359960840a80158a44b --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Hero.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ +// 五.定义英雄类(Hero) +//1.英雄类中的属性包括:姓名、攻击力、防御力、生命值和魔法值; +//2.方法包括:攻击、介绍。 +//3.在主方法中实例化英雄对象,赋值并调用方法 + internal class Hero + { + string name;//姓名 + double attack;//攻击力 + double protect;//防御力 + double live;//生命值 + double magic;//魔法值 + + public string Name { get => name; set => name = value; } + public double Attack { get => attack; set => attack = value; } + public double Protect { get => protect; set => protect = value; } + public double Live { get => live; set => live = value; } + public double Magic { get => magic; set => magic = value; } + + public void Heriinfo() + { + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"攻击力{attack}"); + Console.WriteLine($"防御力{protect}"); + Console.WriteLine($"生命值{live}"); + Console.WriteLine($"魔法值{magic}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Library.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Library.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cf0e25ae46fb3446353e88f94f59b4fd460874b7 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Library.cs" @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ +//三.定义一个图书类 +//1.定义字段存放图书的编号、书名、价格、出版社、作者信息; +//2.对价格进行赋值限制,小于0价格,赋值为0 +//3.在图书类中定义一个方法输出图书信息; +//4.在主方法实例化对象,赋值并输出 + internal class Library + { + //定义 + int id;//编号 + string name;//书名 + double price;//价格 + string press;//出版社 + string author;//作者信息 + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public double Price + { + get => price; + set + { + if (value < 0) + { + price = 0; + } + else + { + price = value; + } + } + } + public string Press { get => press; set => press = value; } + public string Author { get => author; set => author = value; } + + public void Libraryinfo() + { + Console.WriteLine($"编号:{id}"); + Console.WriteLine($"书名:{name}"); + Console.WriteLine($"价格:{price}"); + Console.WriteLine($"出版社:{press}"); + Console.WriteLine($"作者信息:{author}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7032c1c57521af59b0655b7c58535547a3336c91 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Program.cs" @@ -0,0 +1,131 @@ +namespace 类 +{ + internal class Program + { + static void Main(string[] args) + { + /** + * 一. 定义一个用户类 +1.定义字段存放用户的账号、用户名和密码; +2.在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息; +3.在用户类中定义一个 登录身份辨认的方法:规则为用户名为“admin”和密码为“123456”时返回“管理员”,否则返回“普通用户”; +4.在主方法中实例化用户类的对象,然后对其账号、用户名和密码赋值 +5.在主方法中用实例化的对象调用方法,输出用户对象的信息和身份(管理员或者普通用户) + */ + User user1 = new User(); + user1.Id = 1; + user1.Name = "admin"; + user1.Password = "123456"; + + User user2 = new User(); + user2.Id = 2; + user2.Name = "陈qq"; + user2.Password = "5641823"; + + Console.WriteLine("用户1的信息"); + user1.Userinfo(); + + Console.WriteLine("用户2的信息"); + user2.Userinfo(); + + + /** + * 二. 定义一个学生类 +1.定义字段存放学生的学号、姓名、性别、年龄、专业信息; +2.对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; +3.在学生类中定义一个方法输出学生信息。 +4. 在主方法实例化学生对象,赋值并输出 + + */ + Console.WriteLine("\n"); + Student student1 = new Student(); + student1 .Id = 22; + student1.Name = "陈倩倩"; + student1.Sex = '女'; + student1.Age = 20; + student1.Major = "计算机"; + Console.WriteLine("学生1的个人信息"); + student1.Studentinfo(); + + Student student2 = new Student(); + student2.Id = 22; + student2.Name = "陈倩倩"; + student2.Sex = '女'; + student2.Age = 220; + student2.Major = "计算机"; + Console.WriteLine("学生2的个人信息"); + student2.Studentinfo(); + + //三.定义一个图书类 + //1.定义字段存放图书的编号、书名、价格、出版社、作者信息; + //2.对价格进行赋值限制,小于0价格,赋值为0 + //3.在图书类中定义一个方法输出图书信息; + //4.在主方法实例化对象,赋值并输出 + Console.WriteLine("\n"); + + Library tu1= new Library(); + tu1.Id = 2; + tu1.Name = "安徒生童话"; + tu1.Price = -1; + tu1.Press = "湖南少年儿童出版社"; + tu1.Author = "汉斯·克里斯汀·安徒生"; + Console.WriteLine("图书1的信息"); + tu1.Libraryinfo(); + + Library tu2 = new Library(); + tu2.Id = 6; + tu2.Name = "红楼梦"; + tu2.Price = 800; + tu2.Press = "中国艺术研究院"; + tu2.Author = "曹雪芹"; + Console.WriteLine("图书2的信息"); + tu2.Libraryinfo(); + + // 四.定义一个敌人类 + //1.定义可以存放敌人的血量、攻击力和魔法值字段; + //2.要求敌人的血量、攻击力和魔法值都只能设置为大于等于0的值;如果小于0则将字段值设置为0 + //3.在类中定义方法代表敌人具有攻击和逃跑的行为 + //4.在主方法中实例化2个敌人对象,为属性赋值,并输出对象的属性值; + //5.使用一个对象调用攻击方法,使用一个对象调用逃跑方法 + Console.WriteLine("\n"); + Enemy enemy1 = new Enemy(); + enemy1.Name = "陈qq"; + enemy1.Blood = 1253; + enemy1.Aggressivity = 125864; + enemy1.Magic = 568; + Console.WriteLine($"敌人1的信息"); + enemy1.Enemyinfo(); + + Enemy enemy2 = new Enemy(); + enemy2.Name = "林也"; + enemy2.Blood = 84579; + enemy2.Aggressivity = -14795; + enemy2.Magic = -568; + Console.WriteLine($"敌人2的信息"); + enemy2.Enemyinfo(); + + // 五.定义英雄类(Hero) + //1.英雄类中的属性包括:姓名、攻击力、防御力、生命值和魔法值; + //2.方法包括:攻击、介绍。 + //3.在主方法中实例化英雄对象,赋值并调用方法 + Console.WriteLine("\n"); + Hero hero1 = new Hero(); + hero1.Name = "巴啦啦小魔仙"; + hero1.Attack = 99999999; + hero1.Protect = 10000000000; + hero1.Live = 154795435812; + hero1.Magic = 125479548631215; + Console.WriteLine("英雄1的信息"); + hero1.Heriinfo(); + + Hero hero2 = new Hero(); + hero2.Name = "古拉拉黑暗之神"; + hero2.Attack = 5648; + hero2.Protect = -1; + hero2.Live = -2584; + hero2.Magic = 0; + Console.WriteLine("英雄2的信息"); + hero2.Heriinfo(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Student.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3bd4bacda7a8feb7a174d0a8f0eff9ef6fa6539b --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/Student.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + /** + * 二. 定义一个学生类 +1.定义字段存放学生的学号、姓名、性别、年龄、专业信息; +2.对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; +3.在学生类中定义一个方法输出学生信息。 +4. 在主方法实例化学生对象,赋值并输出 + + */ + internal class Student + { + int id;//学号 + string name;//姓名 + char sex;//性别 + int age;//年龄 + string major;//专业信息 + + //属性 + public int Id { get=>id; set=>id = value; } + public string Name { get=>name;set=>name = value; } + public char Sex { get=>sex;set=>sex = value; } + //(小于0或者大于128岁),该年龄值为0 + public int Age + { + get => age; + set + { + if (value < 0 || value > 128) + { + age = 0; + } + else + { + age = value; + } + } + } + + public string Major { get=>major;set=>major = value; } + + public void Studentinfo() + { + Console.WriteLine($"学号:{id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"性别:{sex}"); + Console.WriteLine($"年龄:{age}"); + Console.WriteLine($"专业信息:{major}"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/User.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c48629cbd2616a8050032a0bede25c56af53ce4a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\261\273/User.cs" @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + /** + * 一. 定义一个用户类 +1.定义字段存放用户的账号、用户名和密码; +2.在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息; +3.在用户类中定义一个 登录身份辨认的方法:规则为用户名为“admin”和密码为“123456”时返回“管理员”,否则返回“普通用户”; +4.在主方法中实例化用户类的对象,然后对其账号、用户名和密码赋值 +5.在主方法中用实例化的对象调用方法,输出用户对象的信息和身份(管理员或者普通用户) + + + */ + internal class User + { + int id;//账户 + string name;//用户名 + string password;//密码 + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public string Password + { + get => password; + set + { + if(value.Length>=6 && value.Length <= 10) + { + password = value; + } + else + { + value = "123456"; + } + } + } + public string Ff() + { + if(Name=="admin" && Password == "123456") + { + return "管理员"; + } + else + { + return "普通用户"; + } + } + public void Userinfo() + { + Console.WriteLine($"账号:{id}"); + Console.WriteLine($"用户名:{name}"); + Console.WriteLine($"密码:{password}"); + Console.WriteLine($"身份:{Ff()}"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5a000f6091746a52b3e45634368e94e6d3082635 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Program.cs" @@ -0,0 +1,31 @@ +namespace 重载 +{ + internal class Program + { + static void Main(string[] args) + { + /** + *定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 + 提示:计算圆的面积传半径,计算长方形面积传长和宽。 + */ + area mj = new area(); + Console.WriteLine("圆的面积"+mj.Circlearea(2)); + Console.WriteLine("长方形的面积"+mj.Rectangleare(2,5)); + + /**创建一个名为计算工具类 SumUtils,在类中定义4个方法: + 计算两个整数相加、 + 两个小数相加、 + 两个字符串相加、 + 以及从 1 到指定整数的和的方法。 + 在 Main 方法中分别调用定义好的方法。 + 提示:根据题目要求,分别定义 3 个带两个参数的方法,以及一个带一个整型参数的方法, + 四个方法名相同。*/ + Sumutils sum= new Sumutils(); + Console.WriteLine("整数相加等于"+sum.Zsum(1,1)); + Console.WriteLine("小数相加等于"+sum.Xsum(1.1,1.1)); + Console.WriteLine("字符串相加等于" + sum.Ssum("哈哈哈","嘿嘿")); + Console.WriteLine("1到10的和是" + sum.Sum(10)); + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Sumutils.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Sumutils.cs" new file mode 100644 index 0000000000000000000000000000000000000000..35e25d1a29c28cee77f5526c3785be8203ee0e40 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/Sumutils.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 重载 +{ + /** 创建一个名为计算工具类 SumUtils,在类中定义4个方法: + 计算两个整数相加、 + 两个小数相加、 + 两个字符串相加、 + 以及从 1 到指定整数的和的方法。 + 在 Main 方法中分别调用定义好的方法。 + 提示:根据题目要求,分别定义 3 个带两个参数的方法,以及一个带一个整型参数的方法, + 四个方法名相同。*/ + internal class Sumutils + { + public int Zsum(int a,int b) + { + return a+b; + } + public double Xsum(double a,double b) + { + return a+b; + } + public string Ssum(string a,string b) + { + return a+b; + } + public int Sum(int a) + { + int sum = 0; + for(int i = 1; i < a; i++) + { + sum += i; + } + return sum; + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/area.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/area.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e218d192f13baf1676e0d99f05f3909af807bbf7 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\351\207\215\350\275\275/area.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 重载 +{ + /** + *定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 +提示:计算圆的面积传半径,计算长方形面积传长和宽。 + + */ + internal class area + { + public double Circlearea(double r) + { + return r * r * 3.14; + } + public double Rectangleare(double height,double wide) + { + return height * wide; + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Person.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2bda1f57add46df71d2f792acbfc4228f2810381 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Person.cs" @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public class Person + { + //编号(Id)、姓名(Name)、性别(Sex)、身份证号(Cardid)、联系方式(Tel) + int id;//编号 + string name;//姓名 + char sex;//性别 + int cardid;//身份证 + int tel;//联系方式 + + //属性 + public int Id { get; set; } + public string Name { get; set; } + public char Sex { get; set; } + public int Cardid { get; set; } + public int Tel { get; set; } + + //无参构造 + public Person() { } + //有参构造 + public Person(int id,string name,char sex,int cardid,int tel) + { + this.id = id; + this.name = name; + this.sex = sex; + this.cardid = cardid; + this.tel = tel; + } + //输出 + public void Personinfo() + { + Console.WriteLine($"编号:{id}"); + Console.WriteLine($"姓名{name }"); + Console.WriteLine($"性别{sex}"); + Console.WriteLine($"身份证{cardid}"); + Console.WriteLine($"联系方式{tel}"); + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8c1b89244ffc4b5abaac4425b828e635fec84a3f --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Program.cs" @@ -0,0 +1,29 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + // 一、 假设要完成一个学校的校园管理信息系统,在员工管理系统中有不同的人员信息,包括学生信息、教师信息等。 + //学生的字段:编号(Id)、姓名(Name)、性别(Sex)、身份证号(Cardid)、联系方式(Tel)、专业(Major)、年级(Grade) + //教师的字段:编号(Id)、姓名(Name),性别 (Sex)、身份证号(Cardid)、联系方式(Tel)、职称(Title)、工资号(Wageno) + //方法一: + //为学生信息、教师信息创建两个类,并在两个类中分别定义属性和方法: + //学生类中定义编号(Id)、姓名(Name)、性别(Sex)、身份证号(Cardid)、联系方式(Tel)、专业(Major)、年级(Grade)7 个属性,并定义一个方法在控制台输出这些属性的值。 + + //教师类(Teacher)中定义编号(Id)、姓名(Name),性别 (Sex)、身份证号(Cardid)、联系方式(Tel)、职称(Title)、工资号(Wageno),并将上述属性输岀到控制台。 + //方法二: + //将 Student 类和 Teacher 类中共有的 属性抽取出来定义为一个类Person,并让Student和Teacher继承Person + //每个类都要有一个输出属性的方法。 + //每个类都要有初始化数据的有参构造方法。 + Student stu1 = new Student(12,"陈qq",'女',15464,54875,"软件技术","大一"); + stu1.Studentinfo(); + + Teacher tea1=new Teacher(01,"刘苏梦",'女',4579545,44745555,"语文老师","84756"); + tea1.Teacherinfo(); + + + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Student.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4f601bcdd2d252d155246627b522fe6d36e100ba --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Student.cs" @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + //专业(Major)、年级(Grade) + //并定义一个方法在控制台输出这些属性的值。 + public class Student : Person + { + string major;//专业 + string grade;//年级 + + //属性 + public string Major { get => major; set => major = value; } + public string Grade { get => grade ; set => grade = value; } + + //无参构造 + public Student() { } + //无参构造 + public Student(int id, string name, char sex, int cardid, int tel,string major, string grade) + { + this.Id = id; + this.Name = name; + this.Sex = sex; + this.Cardid = cardid; + this.Tel = tel; + this .Major = major; + this .Grade = grade; + } + + //输出 + public void Studentinfo() + { + Console.WriteLine($"编号:{Id}"); + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"性别:{Sex}"); + Console.WriteLine($"身份证:{Cardid}"); + Console.WriteLine($"联系电话:{Tel}"); + Console.WriteLine($"专业:{major}"); + Console.WriteLine($"年级 :{grade }"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Teacher.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Teacher.cs" new file mode 100644 index 0000000000000000000000000000000000000000..75a5705b5f8d198fd0e9831539ca13a9e6cc4cc6 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\240\241\345\233\255\347\256\241\347\220\206/Teacher.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + //职称(Title)、工资号(Wageno) + //并将上述属性输岀到控制台。 + public class Teacher:Person + { + string title;//职称 + string wageno;//工资号 + + //属性 + public string Title { get => title;set =>title =value ; } + public string Wageno { get => wageno ; set => wageno = value; } + //无参构造 + public Teacher() { } + //有参构造 + public Teacher(int id, string name, char sex, int cardid, int tel, string title, string wageno) + { + this.Id = id; + this.Name = name; + this.Sex = sex; + this.Cardid = cardid; + this.Tel = tel; + this.Title = title; + this.Wageno = wageno; + } + + //输出 + public void Teacherinfo() + { + Console.WriteLine($"编号:{Id}"); + Console.WriteLine($"姓名:{Name}"); + Console.WriteLine($"性别:{Sex}"); + Console.WriteLine($"身份证:{Cardid}"); + Console.WriteLine($"联系电话:{Tel}"); + Console.WriteLine($"职称:{title}"); + Console.WriteLine($"工资号:{wageno}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Hero.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d7f4da2767480ae409336a2d82a8efc68c3fdef2 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Hero.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏 +{ + public class Hero + { + //角色介绍,角色昵称,攻击力,防御力,速度 + + string introduce;//角色介绍 + string name;//角色昵称 + int gjl;//攻击力 + int fyl;//防御力 + double fast;//速度 + + + public string Introduce{ get => introduce; set => introduce = value; } + public string Name { get => name; set => name = value; } + public int Gjl { get => gjl; set => gjl = value; } + public int Fyl{ get => fyl; set => fyl = value; } + public double Fast{ get => fast; set => fast = value; } + + public Hero() { } + + public Hero(string name,string Introduce,int gjl,double fast,int fyl) + { + this .Introduce = Introduce; + this .Name = name; + this .gjl = gjl; + this .fast = fast; + this .fyl = fyl; + } + public void Heroinfo() + { + Console.WriteLine($"角色介绍:{introduce}"); + Console.WriteLine($"角色昵称:{name}"); + Console.WriteLine($"攻击力:{gjl}"); + Console.WriteLine($"防御力:{fyl}"); + Console.WriteLine($"速度:{fast}"); + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8320f3c8c9fded35b31e6c99a69c5b22b0904891 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Program.cs" @@ -0,0 +1,27 @@ +namespace 游戏 +{ + internal class Program + { + static void Main(string[] args) + { +// 二、使用类来描述游戏中的角色。 +//在很多RPG游戏中,第一次打开游戏,都会先让你创建自己的“英雄”,或者自己要扮演的角色。这些英雄或者角色都是我们游戏中的“对象”,所以在开发的时候,我们需要针对每个角色都要写相应的类来描述。 +//见英雄文件夹的图片。 +//分析1: 角色具有以下信息(简单数据) +//字段:角色名字,角色介绍,角色昵称,攻击力,防御力,速度。 +//方法:每个角色都有三个不同的攻击技能。 +//分析2:四个英雄的公共数据?公共数据向上抽取,抽象成一个Hero类,然后四个英雄继承这个Hero类,然后编写各自特有的类成员。 + Skill hero1 = new Skill("埃洛克","埃洛克是一名来自日边境的勇士。他是圣约英雄中名副其实的拳术好手。他用毁灭性的符文魔法和无情的拳术攻击消灭敌人。",99,75,60,"碎石打击","烈焰锚钩","战斗咆哮"); + hero1.Heroinfo(); + Console.WriteLine("\t"); + Skill hero2 = new Skill("泰拉", "泰拉是为复仇而来的勇者。她挥舞法杖,将愤怒转化为强大的元素魔法和攻击力,因此战无不胜。", 90, 75, 70, "巨浪冲击", "元素突击", "复仇杀戮"); + hero2.Heroinfo(); + Console.WriteLine("\t"); + Skill hero3 = new Skill("卢卡斯", "卢卡斯是一名彬彬有礼的剑客,能控制源质能量。他一手持剑战斗,另一手辅助攻击。",90, 60, 75, "减速陷阱", "能量浪潮", "旋风剑舞"); + hero3.Heroinfo(); + Console.WriteLine("\t"); + Skill hero4 = new Skill("洛菲", "洛菲是一名攻击迅猛且擅长送魔法的时空旅行者,喜欢利用她的幻想伙伴迷惑、吸引并摧毁敌人。", 85, 55,100, "能量精灵", "暗影传送", "时空迸裂"); + hero4.Heroinfo(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Skill.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Skill.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d40a4301d835b14e0734cdda7f47b95da5dd9388 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/\346\270\270\346\210\217/Skill.cs" @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏 +{ + public class Skill:Hero + { + //攻击技能 + string one;//第一技能 + string two;//第二技能 + string three;//第三技能 + + public string One { get=>one; set=>one=value; } + public string Two { get => two ; set => two = value; } + public string Three { get => three; set => three = value; } + + public Skill() { } + + public Skill(string name,string Introduce, int gjl, double fast, int fyl,string one,string two,string three) + { + this .Introduce = Introduce ; + this .Name = name ; + this .Gjl = gjl ; + this .Fast = fast ; + this .Fyl = fyl ; + this .One = one ; + this .Two = two ; + this .Three = three ; + + } + + public void Skillinfo() + { + Console.WriteLine($"角色介绍:{Introduce}"); + Console.WriteLine($"角色昵称:{Name}"); + Console.WriteLine($"攻击力:{Gjl}"); + Console.WriteLine($"防御力:{Fyl}"); + Console.WriteLine($"速度:{Fast}"); + Console.WriteLine($"第一技能:{one}"); + Console.WriteLine($"第二技能:{two}"); + Console.WriteLine($"第三技能:{three}"); + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/ArrayUtil.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/ArrayUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1a658c5a61ca77cf9a29927ad62ad69d65a440f2 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/ArrayUtil.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态方法 +{ + internal class ArrayUtil + { + public static bool Array(int a) + { + char[] chars = new char[a]; + + if (chars == null || chars.Length == 0) + { + return true; + } + return false; + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..004831b002290ad59f6efe2f2b0143084b0f55d1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,21 @@ +namespace 静态方法 +{ + internal class Program + { +// 1、写一个工具类StringUtil,在里面定义一个静态方法,用来判断字符串是否为空。 +//如果字符串是null,或者字符串是空"",或者字符串是N个空格" ",那这个方法返回true,否则返回false +//然后在主类中(有Main方法的类)调用测试。 + + static void Main(string[] args) + { + Console.WriteLine(StringUtil.IsEmpty("")); + Console.WriteLine(StringUtil.IsEmpty(" ")); + Console.WriteLine(StringUtil.IsEmpty(" g ")); + Console.WriteLine(StringUtil.IsEmpty(null)); + + Console.WriteLine(ArrayUtil.Array(0)); + Console.WriteLine(ArrayUtil.Array(257)); + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/StringUtil.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/StringUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e79ae3037a647a926aa1d6a86c73f1458f33a7cc --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/StringUtil.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态方法 +{ +// 1、写一个工具类StringUtil,在里面定义一个静态方法,用来判断字符串是否为空。 +//如果字符串是null,或者字符串是空"",或者字符串是N个空格" ",那这个方法返回true,否则返回false +//然后在主类中(有Main方法的类)调用测试。 + + internal class StringUtil + { + public static bool IsEmpty(string str) + { + if (str == null || str == "") + { + return true; + } + char[] arrchar = str.ToCharArray(); + for (int i = 0; i < arrchar.Length; i++) + { + if (arrchar[i] != ' ') + { + return false; + } + + } + return true; + + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/ArrayUtil.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/ArrayUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1a658c5a61ca77cf9a29927ad62ad69d65a440f2 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/ArrayUtil.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态方法 +{ + internal class ArrayUtil + { + public static bool Array(int a) + { + char[] chars = new char[a]; + + if (chars == null || chars.Length == 0) + { + return true; + } + return false; + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..004831b002290ad59f6efe2f2b0143084b0f55d1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/Program.cs" @@ -0,0 +1,21 @@ +namespace 静态方法 +{ + internal class Program + { +// 1、写一个工具类StringUtil,在里面定义一个静态方法,用来判断字符串是否为空。 +//如果字符串是null,或者字符串是空"",或者字符串是N个空格" ",那这个方法返回true,否则返回false +//然后在主类中(有Main方法的类)调用测试。 + + static void Main(string[] args) + { + Console.WriteLine(StringUtil.IsEmpty("")); + Console.WriteLine(StringUtil.IsEmpty(" ")); + Console.WriteLine(StringUtil.IsEmpty(" g ")); + Console.WriteLine(StringUtil.IsEmpty(null)); + + Console.WriteLine(ArrayUtil.Array(0)); + Console.WriteLine(ArrayUtil.Array(257)); + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/StringUtil.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/StringUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e79ae3037a647a926aa1d6a86c73f1458f33a7cc --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/\351\235\231\346\200\201\346\226\271\346\263\225/StringUtil.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态方法 +{ +// 1、写一个工具类StringUtil,在里面定义一个静态方法,用来判断字符串是否为空。 +//如果字符串是null,或者字符串是空"",或者字符串是N个空格" ",那这个方法返回true,否则返回false +//然后在主类中(有Main方法的类)调用测试。 + + internal class StringUtil + { + public static bool IsEmpty(string str) + { + if (str == null || str == "") + { + return true; + } + char[] arrchar = str.ToCharArray(); + for (int i = 0; i < arrchar.Length; i++) + { + if (arrchar[i] != ' ') + { + return false; + } + + } + return true; + + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Add.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Add.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4a802ea6b89d18729e1015da7ef0a4083b5520ae --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Add.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Add : Calculate + { + public Add(int a, int b) : base(a, b) + { + } + public override void DisplayResult() + { + base.DisplayResult(); + Console.WriteLine($"和是{a}+{b}={a + b}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Calculate.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Calculate.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e4c0efc8bbb15e469a52a91e5cc38b6ccc1f94f6 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Calculate.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Calculate + { + protected int a { get; set; } + protected int b { get; set; } + + public Calculate(int a, int b) + { + this.a = a; + this.b = b; + } + + public virtual void DisplayResult() + { + + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Div.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Div.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a464df694b4c901b982729444d383412fde997c2 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Div.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Div : Calculate + { + public Div(int a, int b) : base(a, b) + { + } + public override void DisplayResult() + { + base.DisplayResult(); + Console.WriteLine($"商是{a}/{b}={a / b}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Mul.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Mul.cs" new file mode 100644 index 0000000000000000000000000000000000000000..15efd4dffb54d4d6e999e3db6bb02bc7c69a11f7 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Mul.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Mul : Calculate + { + public Mul(int a, int b) : base(a, b) + { + } + public override void DisplayResult() + { + base.DisplayResult(); + Console.WriteLine($"积是{a}*{b}={a * b}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0f500933750bebd757d992379ea9f2b93ad8ee8d --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Program.cs" @@ -0,0 +1,53 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + //一、编写一个控制台应用程序,接受用户输入的两个整数和一个操作符,以实现对两个整数的加、减、乘、除运算,并显示出计算结果。 + + //1、创建Calculate基类,其中包含两个整型的protected成员,用以接收用户输入的两个整数。定义一个DisplayResult()虚方法,计算并输出结果。 + //2、定义四个类继承自Calculate类,分别重写DisplayResult()方法,实现两个整数的加、减、乘、除运算,并输出结果。 + //3、根据用户输入的操作符,实例化相应的类,完成运算并输出结果。 + //4、在主类中添加一个方法,形参为父类对象,根据传递实参的类型,调用方法,实现计算和显示结果。 + + Console.WriteLine("请输入第一个整数:"); + int a=Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("\n"); + + Console.WriteLine("请输入第二个整数:"); + int b=Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("\n"); + + Console.WriteLine("请输入要用的符号:"); + string sign=Console.ReadLine(); + Calculate calculate = null; + + if(sign == "+") + { + calculate = new Add(a, b); + + }else if(sign == "-") + { + calculate = new Sub(a, b); + }else if (sign == "*") + { + calculate = new Mul(a, b); + } + else if(sign == "/") + { + calculate = new Div(a, b); + } + + Calculate(calculate); + + + + + } + public static void Calculate(Calculate calculate) + { + calculate.DisplayResult(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Sub.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Sub.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c95797f3efb5cb442a8c8572b4124ef7c2b363b1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\212\240\345\207\217\344\271\230\351\231\244/Sub.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Sub : Calculate + { + public Sub(int a, int b) : base(a, b) + { + } + public override void DisplayResult() + { + base.DisplayResult(); + Console.WriteLine($"差是{a}-{b}={a - b}"); + } + } + } + diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Circle.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Circle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6822aa97e3a87a4b8ebe51887d88e9c14cfcf993 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Circle.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 形状 +{ + internal class Circle:Shape + { + + + public double Radius { get; set; } + public Circle() { } + + public Circle(double radius) + { + Radius = radius; + } + + public override void GetArea() + { + Console.WriteLine(3.14 * Radius * Radius); + + + + + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..86c31bed877d5a51f1176c3eaf6568f068c4b936 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Program.cs" @@ -0,0 +1,45 @@ +namespace 形状 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("请输入圆的半径:"); + double radius=Convert.ToDouble(Console.ReadLine()); + Console.WriteLine("\n"); + + Console.WriteLine("请输入圆的颜色:"); + string color = Convert.ToString(Console.ReadLine()); + Console.WriteLine("\n"); + + Circle circle=new Circle(radius); + GetArea(circle); + + + Console.WriteLine("请输入正方形边长是:"); + double sidelen=Convert.ToDouble(Console.ReadLine()); + Console.WriteLine("\n"); + + Console.WriteLine("请输入正方形的颜色是:"); + string colors=Console.ReadLine(); + Console.WriteLine("\n"); + + Square square = new Square(sidelen,color); + GetArea(square); + + + + + + + } + public static void GetArea(Circle circle) + { + circle.GetArea(); + } + public static void GetArea(Square square) + { + square.GetArea(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Shape.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Shape.cs" new file mode 100644 index 0000000000000000000000000000000000000000..601ce4635c654d0bd4aa895b6bcf776928c2c9b9 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Shape.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 形状 +{ + internal class Shape + { + public string color { get; set; } + public double Mian { get; set; } + + public Shape() + { + } + + public Shape(string color) + { + this.color = color; + } + + public virtual void GetArea() + { + Console.WriteLine($"面积是:{Mian}"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Square.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Square.cs" new file mode 100644 index 0000000000000000000000000000000000000000..562679c60129c20706a8f87dd0b803ee531e3500 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\275\242\347\212\266/Square.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 形状 +{ + internal class Square:Shape + { + + + public double Sidelen { get; set; } + public Square() { } + public Square( double sidelen,string color) : base(color) + { + Sidelen = sidelen; + } + + public override void GetArea() + { + Console.WriteLine(Sidelen * Sidelen); + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f1bb37d4881727739c7141a4d1e4aa8caf85b284 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal abstract class Animal + { + public string Name { get; set; } + + + public abstract void Eat(); + + + public void Sleep() + { + Console.WriteLine($"{Name}会睡觉"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" new file mode 100644 index 0000000000000000000000000000000000000000..de876d54e95d23fe4deb4cf169103ea032587c66 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal class Cat:Animal,Swim + { + public override void Eat() + { + Console.WriteLine($"{Name}喜欢吃猫粮"); + } + public void Climb() + { + Console.WriteLine($"{Name}会爬树"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Climb.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Climb.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6a26def9435c092e9a6ed8d64defe57a99eb0b76 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Climb.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal interface Climb + { + public void Climbb() + { + Console.WriteLine("会爬树"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Dog.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Dog.cs" new file mode 100644 index 0000000000000000000000000000000000000000..850d7fd19eddbfd17af3bd1308f0f4f573210d06 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Dog.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal class Dog : Animal, Swim + { + public override void Eat() + { + Console.WriteLine($"{Name}会吃骨头"); + } + public void Swim() + { + Console.WriteLine($"{Name}会狗爬式游泳"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Duck.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Duck.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e12eb73da4ee16eb14304c29e47c30faac710cd --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Duck.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal class Duck : Animal, Swim + { + public override void Eat() + { + Console.WriteLine($"{Name}会吃东西"); + } + + public void Swim() + { + Console.WriteLine($"{Name}会鸭式游泳"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Monkey.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Monkey.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a0d389a7589669ab79b9ae6d4d3cb54318528007 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Monkey.cs" @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal class Monkey + { + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1f28ddf85abcb4953a4c8adb0b3513e28c1a1fcd --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" @@ -0,0 +1,18 @@ + namespace Animal +{ + internal class Program + { + + //猫、狗、鸭、猴,(吃、睡觉、游泳、爬树) + //所有动物都有吃的方法 + //狗和鸭会游泳,不会爬树 + //猫和猴不会游泳会爬树 + //将吃的方法定义在父类方法中,将游泳和爬树的技能定义为接口 + //所有子类继承父类后,再去继承相应的接口实现技能 + + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swim.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swim.cs" new file mode 100644 index 0000000000000000000000000000000000000000..87c4a1ca0d309bab6541bb3af042f40ae4e7366a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swim.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal interface Swim + { + public void Swimming() + { + Console.WriteLine("会游泳"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Batmobile.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Batmobile.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2713e53382f0a519b20359a17f703bf0646318e1 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Batmobile.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Batmobile:Car,Ifly + { + public override void Run() + { + base.Run(); + } + + public void Fly() + { + Console.WriteLine($"{Name}会飞"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Car.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Car.cs" new file mode 100644 index 0000000000000000000000000000000000000000..63d44581844bba3c4c4aea2a4b9b6efaabd2184a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Car.cs" @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Car + { + public string Name { set; get; } + public string Brand { get; set; } + + public virtual void Run() + { + Console.WriteLine($"{Name}会跑"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Ifly.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Ifly.cs" new file mode 100644 index 0000000000000000000000000000000000000000..33fae4a5bd517ba0a3841a934eecb5cee088f40a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Ifly.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Channels; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal interface Ifly + { + public void Fly() + { + Console.WriteLine("会飞"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b6da8bad4345759a3e9aa518b0271d50eb221817 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\235\231\350\235\240\346\210\230\350\275\246/Program.cs" @@ -0,0 +1,13 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Batmobile batmobile = new Batmobile(); + batmobile.Name = "蝙蝠战车"; + batmobile.Run(); + batmobile.Fly(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Animal.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..44a3794b9e09a3b1489bf768b2b3a34bcab18b2f --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Animal.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Animal + { + public string Name { get; set; } + public virtual void Eat() + { + Console.WriteLine($"{Name}会吃"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Bird.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Bird.cs" new file mode 100644 index 0000000000000000000000000000000000000000..839b478ac9b13eadab35bb7965f0cea96dd95357 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Bird.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Bird:Animal,Ifly + { + public void LayEggs() + { + Console.WriteLine($"{Name}会下蛋"); + } + public override void Eat() + { + base.Eat(); + } + public void TakeOff() + { + Console.WriteLine($"{Name}起飞了"); + } + public void Fly() + { + Console.WriteLine($"{Name}在飞行中"); + } + public void Land() + { + Console.WriteLine($"{Name}着陆了"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Ifly.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Ifly.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2a7f2f4080833aa415ffcd82545994397e9caabe --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Ifly.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal interface Ifly + { + public void TakeOff() + { + Console.WriteLine("起飞了"); + } + public void Land() + { + Console.WriteLine("着陆了"); + } + public void Fly() + { + Console.WriteLine("飞行中"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Plane.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Plane.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f23bade518318e1421b6f5db5101fe7a7e4609d7 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Plane.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Plane:Traffic,Ifly + { + public override void CarryPassange() + { + Console.WriteLine("飞机能载人"); + } + + public void TakeOff() + { + Console.WriteLine($"{Name} 起飞了"); + } + public void Fly() + { + Console.WriteLine($"{Name}在飞行中"); + } + public void Land() + { + Console.WriteLine($"{Name}着陆了"); + } + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e1e4451b1ba40caa6f933c442a5512d98a3e6771 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Program.cs" @@ -0,0 +1,34 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Plane plane = new Plane(); + plane.Name = "飞机"; + plane.TakeOff(); + plane.Fly(); + plane.Land(); + plane.CarryPassange(); + Console.WriteLine("\n"); + + Bird bird = new Bird(); + bird.Name = "小鸟"; + bird.TakeOff(); + bird.Fly(); + bird.Land(); + bird.LayEggs(); + bird.Eat(); + + Console.WriteLine("\n"); + + Superman superman = new Superman(); + superman.Name = "超人"; + superman.Eat(); + superman.TakeOff(); + superman.Fly(); + superman.Land(); + + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Superman.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Superman.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7cc0282b45d2c76fee73c6512dc3fcc0285803ee --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Superman.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Superman:Animal,Ifly + { + public override void Eat() + { + base.Eat(); + } + public void TakeOff() + { + Console.WriteLine($"{Name}起飞了"); + } + public void Fly() + { + Console.WriteLine($"{Name}在飞行中"); + } + public void Land() + { + Console.WriteLine($"{Name}着陆了"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Traffic.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Traffic.cs" new file mode 100644 index 0000000000000000000000000000000000000000..553e7e64467bcd8fedeffe12724fda70ad22ebe4 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\350\266\205\344\272\272\343\200\201\345\260\217\351\270\237\343\200\201\351\243\236\346\234\272/Traffic.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + + + + internal abstract class Traffic + { + public string Name { get; set; } + public abstract void CarryPassange(); + } + +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5380ce14c955e4eebee49364a901dbdd47736a4c --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,96 @@ +using System.Data; +using System.Data.SqlClient; +namespace Ado +{ + internal class Program + { + static void Main(string[] args) + { + string constr = "server=CODER-DKAVMNYBG\\SQLEXPRESS;uid=sa;pwd=123456;database=Kele"; + SqlConnection con = null; + try + { + + con = new SqlConnection(constr); + SqlCommand cmd = new SqlCommand(); + //增加数据 + cmd.CommandText = "insert into Studentinfo values('林cx',800,009);" + + "insert into Studentinfo values('付咻咻',89,019)" + + "insert into Studentinfo values('Karry',22,003)"; + cmd.Connection = con; + + con.Open(); + + cmd.ExecuteNonQuery(); + int result = cmd.ExecuteNonQuery(); + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result{result}"); + } + else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result{result}"); + } + + //删除数据 + cmd.CommandText = "delete from studentinfo where stuid=8;"; + result=cmd.ExecuteNonQuery(); + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result{result}"); + } + else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result{result}"); + } + + //修改数据 + cmd.CommandText = "update studentinfo set name='林春香'where stuid=009"; + result=cmd.ExecuteNonQuery(); + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result{result}"); + }else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result{result}"); + } + + } + catch(Exception e) + { + Console.WriteLine($"出现异常:{e.Message}"); + } + + finally + { + if ( con != null ) + { + con.Close(); + } + } + + + Console.ReadLine(); + Console.ReadLine(); + Console.ReadLine(); + } + + public static void GetData() + { + string constr = "server=CODER-DKAVMNYBG\\SQLEXPRESS;uid=sa;pwd=123456;database=Kele"; + string sql = "select*from Stuentinfo"; + + SqlDataAdapter adapter = new SqlDataAdapter(constr,sql); + + DataSet ds= new DataSet(); + if(ds!=null&& ds.Tables.Count>0 && ds.Tables[0].Rows.Count > 0) + { + foreach(DataRow item in ds.Tables[0].Rows) + { + Console.WriteLine($"名字:{item[0]},年龄:{item[1]},学号:{item[2]}"); + Console.WriteLine($"名字:{item["name"]},年龄:{item["age"]},学号:{item["stuid"]}"); + } + } + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/sql.sql" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/sql.sql" new file mode 100644 index 0000000000000000000000000000000000000000..4f63c9b4945646f46d2c544fc02de5e371c854cc --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/sql.sql" @@ -0,0 +1,13 @@ +create database Kele; +go +use Kele +create table Studentinfo( +name nvarchar(10), +age int , +stuid int +) + +insert into Studentinfo values('qq',8,008); + +select distinct *from Studentinfo; + diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06c8fec68626eb80b54ef44c252da71d605f6161 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Animal.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class Animal + { + + public string Name { get; set; } + public int Leg { get; set; } + public double Weight { get; set; } + + public Animal() { } + public Animal(string name,int leg, double weight) + { + Name = name; + Leg = leg; + Weight = weight; + } + + public virtual void Eat() + { + Console.WriteLine($"{Name}会吃饭!!"); + + } + + public virtual void Cry() + { + Console.WriteLine($"{Name}会叫"); + } + + public void Sleep() + { + Console.WriteLine($"{Name}会睡觉"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/B.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/B.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ceae7e1b1f51c5814aa56dd2d198507508168aa5 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/B.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace 动物 +{ + internal class B:Animal + { + + + public B(string name, int leg, double weight) : base(name, leg, weight) + { + + } + + public virtual void Fly() + { + Console.WriteLine($"{Name}会飞"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/C.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/C.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c8238ddd798f8b49865238e022658566fd706dbb --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/C.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class C:Animal + { + public string Beard { get; set; } + + public C(string name,int leg,double weight,string beard):base (name,leg,weight) + { + Beard = beard; + } + + public virtual void Night() + { + Console.WriteLine($"{Name}有夜视能力"); + } + } + +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d769e552e45f1a682689f4883dbb9e8d767c5063 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Cat.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class Cat:C + { + + public Cat(string name, int leg, double weight,string beard) : base(name, leg, weight,beard) + { + } + public override void Eat() + { + base.Eat(); + Console.WriteLine($"{Name}喜欢吃小鱼干"); + + } + public override void Cry() + { + base.Cry(); + Console.WriteLine($"{Name}喜欢喵喵叫"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Eagle.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Eagle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f0e7b65c4973f1d34397dd5cbca58de895acc780 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Eagle.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class Eagle:B + { + + public Eagle(string name, int leg, double weight) : base(name, leg, weight) + { + } + public override void Eat() + { + base.Eat(); + Console.WriteLine($"{Name}喜欢吃肉食"); + + } + public override void Cry() + { + base.Cry(); + Console.WriteLine($"{Name}喜欢ying叫"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7d05448adbf1a30d65250464a7a458ab12903ae7 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Program.cs" @@ -0,0 +1,34 @@ +namespace 动物 +{ + internal class Program + { + static void Main(string[] args) + { + Tiger tiger=new Tiger("老虎",4,250.6,"有"); + tiger.Night(); + tiger.Cry(); + tiger.Eat(); + + Console.WriteLine("\n"); + + Cat cat =new Cat("猫咪",4,50.2,"有"); + cat .Eat(); + cat .Cry(); + cat.Night(); + + Console.WriteLine("\n"); + + Eagle eagle = new Eagle("老鹰", 2, 31.5); + eagle.Eat(); + eagle.Cry(); + eagle.Fly(); + + Console.WriteLine("\n"); + + Swallow swallow = new Swallow("小燕子",2,11); + swallow.Eat(); + swallow.Cry(); + swallow.Fly(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swallow.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swallow.cs" new file mode 100644 index 0000000000000000000000000000000000000000..710e02679fd815cd698e7df768844bd53e0049dd --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Swallow.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class Swallow : B + { + + public Swallow(string name, int leg, double weight) : base(name, leg, weight) + { + } + public override void Eat() + { + base.Eat(); + Console.WriteLine($"{Name}喜欢吃虫子"); + + } + public override void Cry() + { + base.Cry(); + Console.WriteLine($"{Name}喜欢叫"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Tiger.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Tiger.cs" new file mode 100644 index 0000000000000000000000000000000000000000..44b76ffde14d54a0449bed4b747d30e5c87c1a0c --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251/Tiger.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物 +{ + internal class Tiger : C + { + public Tiger(string name, int leg, double weight,string beard) : base(name, leg, weight,beard) + { + } + public override void Eat() + { + base.Eat(); + Console.WriteLine($"{Name}喜欢吃肉"); + + } + public override void Cry() + { + base.Cry(); + + Console.WriteLine($"{Name}喜欢嗷嗷叫"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Doctor.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Doctor.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2d51f69731d7449d364d4127344dd3aa7eea92e9 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Doctor.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace 员工类 +{ + internal class Doctor : Yg + { + public Doctor(string name, char sex, int age) : base(name, sex, age) + { + } + + + public override void Do() + { + base.Working(); + Console.WriteLine($"{Name}要做:抓药,临床,针灸"); + } + + + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Dustman.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Dustman.cs" new file mode 100644 index 0000000000000000000000000000000000000000..41fc5c13d825c71295372f285875b31fe054bf09 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Dustman.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Dustman : Yg + { + public Dustman(string name, char sex, int age) : base(name, sex, age) + { + } + + public override void Do() + { + base.Working(); + Console.WriteLine($"{Name}要做:扫厕所,拖大堂等"); + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..158b4d9fb8d6006203f91480665959f883a3dbaa --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Program.cs" @@ -0,0 +1,23 @@ +using System.Numerics; + +namespace 员工类 +{ + internal class Program + { + static void Main(string[] args) + { + Doctor doctor = new Doctor("陈qq", '女', 36); + doctor.Do(); + + Console.WriteLine("\n"); + + Programmer cxy = new Programmer("刘苏萌", '女', 18); + cxy.Do(); + + Console.WriteLine("\n"); + + Dustman qjg = new Dustman("小胡", '男', 51); + qjg.Do(); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Programmer.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Programmer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..007de34c3de7293adb7a57fb2517f11cd8ad801a --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Programmer.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Programmer : Yg + { + public Programmer(string name, char sex, int age) : base(name, sex, age) + { + } + + public override void Do() + { + base.Working(); + Console.WriteLine($"{Name}要做:打代码,写程序,思考"); + + + } + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Yg.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Yg.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf890faaf54deb7f4cf149e9e1b3c3e49982b51d --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245/Yg.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 员工类 +{ + internal class Yg + { + public string Name { get; set; } + public char Sex { get; set; } + public int Age { get; set; } + + public Yg(string name, char sex, int age) + { + Name = name; + Sex = sex; + Age = age; + } + public Yg() { } + + public void Working() + { + Console.WriteLine($"{Name}要去上班"); + } + public virtual void Do() + { + Console.WriteLine($"{Name}做事情"); + } + + } +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Book.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Book.cs" new file mode 100644 index 0000000000000000000000000000000000000000..60b722942f3b0e2821ba88a7e03cc7d1085ac214 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Book.cs" @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 类 +{ + public class Book + { + public int id;//编号 + public string name;//书名 + public double price;//价格 + public string publisher;//出版社 + public string author;//作者 + + //设置属性 + //编号 + public int Id + { + get + { + return id; + } + set + { + id = value; + } + } + //书名 + public string Name + { + get + { + return name; + } + set { name = value; } + } + //价格 + public double Price + { + get { return price; } + set + { + if (price < 0) + { + price = 0; + }else + { price = value; } + } + } + //出版社 + public string Publisher + { + get { return publisher; } + set { publisher = value; } + } + //作者 + public string Author + { + get { return author; } + set { author = value; } + } + //控制台输出 + public void BookIndo() + { + Console.WriteLine($"学号:{this.id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"价格:{price}"); + Console.WriteLine($"出版社:{publisher}"); + Console.WriteLine($"作者:{author}"); + } + } + + +} diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e9528c12da7ffb6d4eba0be7bc6f19c8f41be6d --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,78 @@ +using User; +using 类; + +namespace User +{ + internal class Program + { + static void Main(string[] args) + { + /* 1.定义一个用户类,存放用户的账号、用户名和密码属性; + 在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息;然后在主方法调用输出;*/ + //使用User类实例化出一个User对象 + User user1 = new User(); + + //对user1对象的字段进行赋值 + user1.id = 1; + user1.name = "陈qq"; + user1.password = "Abc45789"; + + //使用User类实例化出一个User对象 + User user2 = new User(); + + //对user2对象的字段进行赋值 + user2.id = 2; + user2.name = "刘sm"; + user2.password = "ABD45786"; + + //控制台输出学生个人信息 + Console.WriteLine("user1对象的数据:"); + user1.PrintIndo(); + + Console.WriteLine("user2对象的数据:"); + user2.PrintIndo(); + /*2.定义一个学生类,存放学生的学号、姓名、性别、年龄、专业信息; + 对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + 在学生类中定义一个方法输出学生信息。 + 在主方法实例化对象,赋值并输出*/ + Student student1 = new Student(); + + student1.id = 3; + student1.name = "陈qq"; + student1.sex = '男'; + student1.Age = 30; + student1.zyxx = "无业游民"; + + Student student2 = new Student(); + student2.id = 4; + student2.name = "yy"; + student2.sex = '女'; + student2.Age = 5; + student2.zyxx = "计算机"; + + //控制台输出学生信息 + Console.WriteLine("student1的学生信息:"); + student1.StudentIndo(); + + Console.WriteLine("student2的学生信息:"); + student2.StudentIndo(); + + + /*3.定义一个图书类,存放图书的编号、书名、价格、出版社、作者信息; + 对价格进行赋值限制,小于0价格,赋值为0 + 在图书类中定义一个方法输出图书信息; + 在主方法实例化对象,赋值并输出*/ + Book book= new Book(); + book.id = 001; + book.name = "《海的女人》"; + book.price= 50; + book.publisher = "北京师范大学出版社"; + book.author = "安徒生"; + + //控制台输出图书信息 + Console.WriteLine("book的图书信息:"); + book.BookIndo(); + } + } +} + diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Student.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ecb4c25a52900eed13da7ba1d248315201ce4df3 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Student.cs" @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace User +{ + + //第二题----------------------- + public class Student + { + public int id;//学号 + public int age;//年龄 + public string name;//姓名 + public char sex;//性别 + public string zyxx;//专业信息 + + //设置属性 + //学号 + public int Id + { + get + { + return id; + } + set { id = value; } + } + //姓名. + public string Name + { + get + { + return name; + } + set { name = value; } + } + //年龄 + public int Age + { + get + { + return age; + } + set + { + if (value < 0 || value > 128) + { + age = 0; + } + else + { + age = value; + } + } + } + //性别 + public char Sex + { + get + { + return sex; + } + set { sex = value; } + } + //专业信息 + public string Zyxx + { + get + { + return zyxx; + } + set + { + zyxx = value; + } + } + //控制台输出Student + public void StudentIndo() + { + Console.WriteLine($"学号:{this.id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"性别:{sex}"); + Console.WriteLine($"年龄:{age}"); + Console.WriteLine($"专业信息:{zyxx}"); + } + } +} \ No newline at end of file diff --git "a/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..25e69a06883cbba9e9abf8c46824cd3035b25e78 --- /dev/null +++ "b/03\346\236\227\346\200\241\347\220\264/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace User +{ + //第一题-------------------- + public class User + { + public int id;//账号 + public string name;//姓名 + public string password;//密码 + + //设置账号,姓名,密码的属性 + public int Id + { + get { return Id; } + set { Id = value; } + } + public string Name + { + get { return Name; } + set { Name = value; } + } + public string Password + { + get { return Password; } + set { Password = value; } + } + //控制台输出 + public void PrintIndo() + { + Console.WriteLine($"账号:{this.id}"); + Console.WriteLine($"姓名:{name}"); + Console.WriteLine($"密码:{password}"); + } + + } +}