diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.metadata.v5.2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.metadata.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..30b744d458262b55d0c4af441f2f2183e3a24637 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.metadata.v5.2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.projects.v5.2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.projects.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..51b6a6405372e810808efc37a753628b61d9369e Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.projects.v5.2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" new file mode 100644 index 0000000000000000000000000000000000000000..0a091e5274f121a7855955ad3545516df46bbe8e Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/FileContentIndex/f9bfa7de-e588-416e-b58e-d01f6ba6c860.vsidx" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/FileContentIndex/f9bfa7de-e588-416e-b58e-d01f6ba6c860.vsidx" new file mode 100644 index 0000000000000000000000000000000000000000..059ad36b54d1e4d58718ba4f6a7f45d5a660526e Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/FileContentIndex/f9bfa7de-e588-416e-b58e-d01f6ba6c860.vsidx" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/FileContentIndex/read.lock" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/FileContentIndex/read.lock" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" new file mode 100644 index 0000000000000000000000000000000000000000..ee376db52d506eed025717dad7c50886e0463916 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.suo" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.suo" new file mode 100644 index 0000000000000000000000000000000000000000..6e8599b02ebfc7f8aa667634aecc63b386743ac7 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/v17/.suo" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.png" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.png" new file mode 100644 index 0000000000000000000000000000000000000000..c36080f5d826f07fb9edd93134818269632fe9ba Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232.png" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/lzq.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/lzq.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f2da57297cf91a9b6172f576cfd700daf5c31d6 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/lzq.cs" @@ -0,0 +1,49 @@ +namespace ref和out +{ + internal class Program + { + static void Main(string[] args) + { + int[] arr = new int[5]; + for (int i = 0; i < arr.Length; i++) + { + Console.WriteLine($"请输入第{i+1}个整数"); + arr[i] = Convert.ToInt32(Console.ReadLine()); + } + + int max = 0; + int min = 0; + int sum = 0; + double avg = 0; + + Get(arr, ref max, ref min, out sum, out avg); + + Console.WriteLine(max); + Console.WriteLine(min); + Console.WriteLine(sum); + Console.WriteLine(avg); + + } + + public static void Get(int[] arr,ref int max,ref int min,out int sum,out double avg) + { + max = arr[0]; + min = arr[0]; + sum = 0; + avg = 0; + for (int i = 0;i < arr.Length;i++) + { + if (arr[i] > max) + { + max= arr[i]; + } + if (arr[i] < min) + { + min= arr[i]; + } + sum += arr[i]; + } + avg = (double)sum / arr.Length; + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\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/11\350\277\236\345\242\236\351\222\261/\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..77bc43bf381b7440acf4accc70062f2f74b1691a --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\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,168 @@ +using System.Globalization; +using System.Security.Cryptography; + +namespace 第三次作业 +{ + internal class 第三次作业 + { + static void Main(string[] args) + { + /* 1.求圆的面积 + 要求用户输入半径的值,打印出以此值为半径的圆的面积 + 求圆的面积的公式:πr²。 + 圆周率π定义成常量取3.14。 + r由用户输入并存入一个变量中,此变量用double比较合适,因为用户可能会输入小数。 + */ + Console.WriteLine("请输入圆的半径:"); + const double π = 3.14f; + Double r = Double.Parse(Console.ReadLine()); + double S = π * r * r; + Console.WriteLine("圆的面积=" + S); + + + /*2.编写一个程序,请用户输入一个四位整数, + * 将用户输入的四位数的千位、百位、十位和个位分别显示出来,如5632, + * 则显示“用户输入的千位为5,百位为6,十位为3,个位为2” + */ + Console.WriteLine("请输入一个四位整数:"); + int num1 = int.Parse(Console.ReadLine()); + Console.WriteLine("千位数是" + num1 / 1000 + "\n" + + "百位数是" + num1 % 1000 / 100 + "\n" + + "十位数是" + num1 % 1000 % 100 / 10 + "\n" + + "个位数是" + num1 % 10); + + + /* 3.用户输入三个数,找出最大的数,打印输出。*/ + Console.WriteLine("请输入第一个三位整数:"); + int first = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入第二个三位整数:"); + int second = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入第三个三位整数:"); + int third = int.Parse(Console.ReadLine()); + if (first < second) + { + if (second < third) + { + Console.WriteLine("最大的数是" + third); + } + else + { + Console.WriteLine("最大的数是" + second); + } + } + else + { + Console.WriteLine("最大的数是" + first); + } + + + /*4.接受用户输入一个数n,求这个数的阶乘;5! = 5 * 4 * 3 * 2 * 1;*/ + Console.WriteLine("请输入一个整数"); + int num2 = int.Parse(Console.ReadLine()); + for (int i = num2 - 1; i >= 1; i--) + { + num2 *= i; + } + Console.WriteLine("这个数的阶乘为" + num2); + + + /* 5.接受用户输入的一个数n,求n到1所有数的阶乘和;n! + (n - 1!) + (n - 2)! +……+1!*/ + Console.WriteLine("请输入一个整数:"); + int num3 = int.Parse(Console.ReadLine()); + int sum = 0; + for (int i = 1; i <= num3; i++) + { + int box = 1; + for (int j = 1; j <= i; j++) + { + box *= j; + } + sum += box; + } + Console.WriteLine(num3 + "到1的所有数的阶乘和为" + sum); + + + /*6.根据用户输入的菱形边长,打印菱形;如边长为3,行数为5*/ + Console.WriteLine(" 请输入菱形的边长x:"); + /*菱形的边长至少为2,且行数一定为奇数*/ + int x = int.Parse(Console.ReadLine()); + /*先打出菱形的上半部分*/ + for (int i = 1; i <= x; i++) + { + for (int j = 1; j <= x - i; j++) + { + Console.Write(" "); + } + for (int k = 1; k <= 2 * i - 1; k++) + { + Console.Write("*"); + } + Console.Write("\n"); + } + /*再打出下半部分*/ + for (int i = x - 1; i >= 1; i--) + { + for (int j = 1; j <= x - i; j++) + { + Console.Write(" "); + } + for (int k = 1; k <= 2 * i - 1; k++) + { + Console.Write("*"); + } + Console.Write("\n"); + } + + + /* 7.用循环打印九九乘法表(用二维数组保存字符串后再打印)*/ + for (int i = 1; i <= 9; i++) { + for (int j = 1; j <= i; j++) { + Console.Write(i + "×" + j + "=" + i * j + "\t"); + } + Console.Write("\n"); + } + + + /*8.输入一行字符串,分别统计出其中英文字母、数字、空格的个数。*/ + Console.Write("请输入一段字符串:"); + int letter = 0; + int num4 = 0; + int space = 0; + string str = Console.ReadLine(); + char[] ch = str.ToCharArray(); + foreach (char i in ch) { + if (i >= 'a' && i <= 'z' || i >= 'A' && i <= 'Z') + { + letter++; + } + else if (i >= '0' && i <= '9') + { + num4++; + } + else if (i == ' ') { + space++; + } + } + Console.Write("字母的个数为" + letter + "个," + "\n" + + "数字的个数为" + num4 + "个," + "\n" + + "空格的个数为" + space + "个," + "\n"); + /*9.在 Main 方法中创建一个 double 类型的数组,并在该数组中存入 5 名学生的考试成绩,计算总成绩和平均成绩。(要求使用foreach语句实现该功能)*/ + double[] score = new double[5]; + double sums = 0; + double avg = 0; + Console.WriteLine("请输入五名同学的成绩:"); + foreach (int i in score) + { + score[i] = double.Parse(Console.ReadLine()); + sums += score[i]; + } + avg = sums / 5; + Console.Write("总分为"+sums+",\n"+"平均分为"+avg); + + + /* 10.定义一个方法,实现一维数组的排序功能,从大到小排序。(不要用Array类的方法)*/ + + + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f90c419a09800f38b4d79b75b5a4ce723f5ec4ef --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,39 @@ +namespace 继承作业二 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("-------------------------------"); + programmer programmer1=new programmer(); + programmer1.name = "小果盯"; + programmer1.ip = "龙岩"; + programmer1.salary = 5000; + programmer1.position = "主管"; + programmer1.dx= 5000; + programmer1.way(); + Console.WriteLine("-------------------------------"); + programmer programmer2=new programmer(); + programmer2.name = "大国定"; + programmer2.ip = "北京"; + programmer2.salary = 2000; + programmer2.position = "程序员"; + programmer2.dx = 5000; + programmer2.way(); + Console.WriteLine("-------------------------------"); + dustman dustman1=new dustman(); + dustman1.name = "小磊"; + dustman1.ip = "哦哦哦"; + dustman1.salary = 3000; + dustman1.position = "秘书"; + dustman1.way2(); + Console.WriteLine("-------------------------------"); + dustman dustman2= new dustman(); + dustman2.name = "重重疯"; + dustman2.ip = "北大"; + dustman2.salary = 1000; + dustman2.position = "清洁工"; + dustman2.way2(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/dustman.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/dustman.cs" new file mode 100644 index 0000000000000000000000000000000000000000..003c578c569af9f401bc6f41a49ed58e8b6e7023 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/dustman.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 dustman:info + { + //秘书和清洁员 + public int salary; + public string position; + + public void way2() + { + Console.WriteLine("姓名:{0}", name); + Console.WriteLine("地址;{0}", ip); + Console.WriteLine("薪水:{0}", salary); + Console.WriteLine("职位:{0}", position); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/info.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/info.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e32816c1333df62568c631d9284868cfd90b16e0 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/info.cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业二 +{ + internal class info + { + public string name; + public string ip; + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/programmer.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/programmer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b791ef81cc6360506880e1a276f837e57b3b8398 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\200.\351\233\207\345\221\230\347\263\273\347\273\237/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:info + { + public int salary; + public string position; + public int dx; + public void way() + { + Console.WriteLine("姓名:{0}",name); + Console.WriteLine("地址;{0}",ip); + Console.WriteLine("薪水:{0}",salary+dx*0.5); + Console.WriteLine("职位:{0}",position); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\211.\345\233\276\345\275\242\347\263\273\347\273\237/da.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\211.\345\233\276\345\275\242\347\263\273\347\273\237/da.cs" new file mode 100644 index 0000000000000000000000000000000000000000..194aa488497a18a6d3a46a3fde527be7f55d6223 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\270\211.\345\233\276\345\275\242\347\263\273\347\273\237/da.cs" @@ -0,0 +1,81 @@ +namespace ͼ +{ + /* ͼࣺ + ܳΣ ıΣ ԲΣ*/ + // ͼλ + class Shape + { + public virtual double GetArea() { return 0; } + public virtual double GetPerimeter() { return 0; } + } + + // + class Triangle : Shape + { + public double A { get; set; } + public double B { get; set; } + public double C { get; set; } + + public override double GetArea() + { + double p = GetPerimeter() / 2; + return Math.Sqrt(p * (p - A) * (p - B) * (p - C)); + } + + public override double GetPerimeter() + { + return A + B + C; + } + } + + // ı + class Quadrilateral : Shape + { + public double A { get; set; } + public double B { get; set; } + public double C { get; set; } + public double D { get; set; } + + public override double GetArea() + { + double p = GetPerimeter() / 2; + return Math.Sqrt((p - A) * (p - B) * (p - C) * (p - D)); + } + + public override double GetPerimeter() + { + return A + B + C + D; + } + } + + // Բ + class Circle : Shape + { + public double R { get; set; } + public override double GetArea() + { + return Math.PI * R * R; + } + + public override double GetPerimeter() + { + return 2 * Math.PI * R; + } + } + + // ʹʾ + class Test + { + static void Main(string[] args) + { + Triangle t = new Triangle { A = 3, B = 4, C = 5 }; + Console.WriteLine($"{t.GetArea()}ܳ{t.GetPerimeter()}"); + + Quadrilateral q = new Quadrilateral { A = 3, B = 4, C = 5, D = 6 }; + Console.WriteLine($"ı{q.GetArea()}ܳ{q.GetPerimeter()}"); + + Circle c = new Circle { R = 5 }; + Console.WriteLine($"Բ{c.GetArea()}ܳ{c.GetPerimeter()}"); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e3266352910000321dd3bb37f97a102085dedf96 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,22 @@ +namespace 学生系统 +{ + internal class Program + { + static void Main(string[] args) + { + specialty specialty1 = new specialty(); + specialty1.name = "王雷"; + specialty1.age = 17; + specialty1.degree = "专科"; + specialty1.spec = "java"; + specialty1.wayone(); + Console.WriteLine("-------------------------------------------"); + Undergraduate un1= new Undergraduate(); + un1.name = "刘文"; + un1.age = 22; + un1.degree = "本科"; + un1.drec = "网络技术"; + un1.waytwo(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Undergraduate.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Undergraduate.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d31d7afed65a30a0cd1523952e7939686ea13ece --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/Undergraduate.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace 学生系统 +{ + internal class Undergraduate:student + { + public string drec; + public void waytwo() + { + Console.WriteLine("学生姓名;{0}", name); + Console.WriteLine("学生年龄;{0}", age); + Console.WriteLine("学生学历;{0}", degree); + Console.WriteLine("学生专业;{0}", drec); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/specialty.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/specialty.cs" new file mode 100644 index 0000000000000000000000000000000000000000..62266d7a775063d944cc97d272c42f68838db91f --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/specialty.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 学生系统 +{ + internal class specialty:student + { + public string spec; + public void wayone() + { + Console.WriteLine("学生姓名:{0}",name); + Console.WriteLine("学生年龄:{0}",age); + Console.WriteLine("学生学历:{0}",degree); + Console.WriteLine("学生专业:{0}", spec); + } + + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/student.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e1d950a2b0183efe4f4acb6358dac47c6fe99fe0 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\214.\345\255\246\347\224\237\347\263\273\347\273\237/student.cs" @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 学生系统 +{ + internal class student + { + public string name;//姓名 + public int age;//年龄 + public string degree;//学位 + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a024982bbe89c14d8a19d86352acf5d18665269e --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,14 @@ +namespace 继承作业二 +{ + internal class Program + { + static void Main(string[] args) + { + Car car = new Car("奔驰", 4, 120, 4); + car.Print(); + + Truck truck = new Truck("重汽", 16, 1200, 200); + truck.Print(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Truck.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Truck.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ac93f21881a40a49f73974f95f8e33c29c1e7a23 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Truck.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; + +namespace ̳ҵ +{ + internal class Truck : Vehicle + { + public int Payload { get; set; } + + public Truck() { } + public Truck(string brand, int wheels, int weight, int payload) : base(brand, wheels, weight) + { + this.Payload = payload; + } + + public void Print() + { + base.Print(); + Console.WriteLine($":{Payload}"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Vehicle.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Vehicle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..360c9c263d2fb318e89e594e24767b459772407a --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/Vehicle.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ̳ҵ +{ + internal class Vehicle + { + public string Brand { get; set; } + public int Wheels { get; set; } + public int Weight { get; set; } + + public Vehicle() { } + public Vehicle(string brand, int wheels, int weight) + { + this.Brand = brand; + this.Wheels = wheels; + this.Weight = weight; + } + + public void Print() + { + Console.WriteLine($"Ʒ:{Brand}"); + Console.WriteLine($"ָ:{Wheels}"); + Console.WriteLine($":{Weight}"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/car.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/car.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fbd643145fe09afa64eaa8788b82bf271ddaa44a --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\344\272\224.\346\261\275\350\275\246\347\263\273\347\273\237/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 + { + public int Loader { get; set; } + public Car() { } + + public Car(string brand, int wheels, int weight, int loader) : base(brand, wheels, weight) + { + this.Loader = loader; + } + + public void Print() + { + base.Print(); + Console.WriteLine($":{Loader}"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Employee.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Employee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d1d89acc8bf4940811b75dbd4866a215591832c9 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Employee.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ̳ҵ +{ + internal class Employee2 + { + //ġ ԱEmployee + //ֶΣޣн + //鳤(GroupLeader) н+1000* + //(Manager) н+1000** ֺ죻Ҫһ ֶΣֺ1000 + //ͻAccountManagerн+1000** ֺ(ֺ*3) + //鳤н + public string Name { get; set; } + public int YearOfSerive { get; set; } // + public double MonthlySalary { get; set; } //н + } +} + diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e49ee14d1c449696d0c22f76986b6439d8f1d47d --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\345\233\233.\345\267\245\350\265\204\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,25 @@ +namespace 继承作业二 +{ + internal class Program + { + static void Main(string[] args) + { + GroupLeader groupLeader = new GroupLeader(); + groupLeader.YearOfSerive = 5; + groupLeader.MonthlySalary = 5000; + Console.WriteLine($"组长的年薪是{groupLeader.GetGroupLeader()}"); + + Manager manager = new Manager(); + manager.YearOfSerive = 5; + manager.MonthlySalary = 7000; + manager.Bouns = 1000; + Console.WriteLine($"经理的年薪是{manager.GetManager()}"); + + AccountManager accountmanager = new AccountManager(); + accountmanager.YearOfSerive = 5; + accountmanager.MonthlySalary = 9000; + accountmanager.Bouns = 1000; + Console.WriteLine($"客户经理的年薪是{accountmanager.GetAccountManager()}"); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.metadata.v5.2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.metadata.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..5ee7673d04bb388d76485d3ff77bbbc36cccbddc Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.metadata.v5.2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.projects.v5.2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.projects.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..3651ad23db4f46a96ddab6a28dafc66b30861195 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/ProjectEvaluation/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.projects.v5.2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" new file mode 100644 index 0000000000000000000000000000000000000000..90b760bd4de16b304c115eeb70b1e11b77a215e6 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/DesignTimeBuild/.dtbcache.v2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/FileContentIndex/5b1522df-f11b-44f2-87cd-ea70a30611f2.vsidx" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/FileContentIndex/5b1522df-f11b-44f2-87cd-ea70a30611f2.vsidx" new file mode 100644 index 0000000000000000000000000000000000000000..484381b3f391074bb2e7f200adfcc43e5541edd8 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/FileContentIndex/5b1522df-f11b-44f2-87cd-ea70a30611f2.vsidx" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/FileContentIndex/read.lock" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/FileContentIndex/read.lock" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" new file mode 100644 index 0000000000000000000000000000000000000000..f9e667b819b46a86135036965be4779a5039d5f8 Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.futdcache.v2" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.suo" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.suo" new file mode 100644 index 0000000000000000000000000000000000000000..4fc2bf341a6ebdd2e6c9a58efa9b9b01ec76531e Binary files /dev/null and "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.vs/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/v17/.suo" differ diff --git "a/11\350\277\236\345\242\236\351\222\261/\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\232.cs" "b/11\350\277\236\345\242\236\351\222\261/\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\232.cs" new file mode 100644 index 0000000000000000000000000000000000000000..612a4914269ad4b5c0582fb8463cce5ab9129d4d --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\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\232.cs" @@ -0,0 +1,123 @@ +using System; + +namespace 第二次作业 +{ + internal class 第二次作业 + { + //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/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.cs" new file mode 100644 index 0000000000000000000000000000000000000000..259067313fa3a5e4c4a3b43d3884fcf87d09a780 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.cs" @@ -0,0 +1,82 @@ +namespace 重载 +{ + internal class Program + { + static void Main(string[] args) + { + //1.定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 + //提示:计算圆的面积传半径,计算长方形面积传长和宽。 + Console.WriteLine("1、计算长方形的面积"); + Console.WriteLine("2、计算圆的面积"); + int i = Convert.ToInt32(Console.ReadLine()); + if(i == 1) + { + Console.WriteLine("请输入长l:"); + double l = Convert.ToDouble(Console.ReadLine()); + Console.WriteLine("请输入宽w:"); + double w = Convert.ToDouble(Console.ReadLine()); + Count_Area count1 = new Count_Area(); + Console.WriteLine($"长方形的面积为{count1.Count(l, w)}"); + } + else if(i == 2) + { + Console.WriteLine("请输入半径r:"); + double r = Convert.ToDouble(Console.ReadLine()); + Count_Area count1 = new Count_Area(); + Console.WriteLine($"圆的面积为{count1.Count(r)}"); + } + else + { + Console.WriteLine("您输入的有误"); + } + + + //2.创建一个名为计算工具类 SumUtils,在类中定义4个方法: + // 计算两个整数相加、 + // 两个小数相加、 + // 两个字符串相加、 + // 以及从 1 到指定整数的和的方法。 + //在 Main 方法中分别调用定义好的方法。 + + //提示:根据题目要求,分别定义 3 个带两个参数的方法,以及一个带一个整型参数的方法, + + // 四个方法名相同。 + SumUntils int1 = new SumUntils(); + Console.WriteLine(int1.Sum(1, 2)); + + SumUntils double1 = new SumUntils(); + Console.WriteLine(double1.Sum(1.1,2.2)); + + SumUntils str1 = new SumUntils(); + Console.WriteLine(str1.Sum("Hello","World")); + } + } + public class Count_Area + { + //1.定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 + //提示:计算圆的面积传半径,计算长方形面积传长和宽。 + public double Count(double l, double w) + { + return l * w; + } + public double Count(double r) + { + return r * r * 3.14; + } + } + public class SumUntils + { + public int Sum(int a,int b) + { + return a + b; + } + public double Sum(double c,double d) + { + return c + d; + } + public string Sum(string e,string f) + { + return e + f; + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c5e529a6887445cea6fc661c1d682a8720099d14 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,103 @@ +using System.Diagnostics; +using System.Xml.Linq; + +namespace 游戏作业 +{ + 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 +//每个类都要有一个输出属性的方法。 +//每个类都要有初始化数据的有参构造方法。 + + + Console.WriteLine("===========作业============"); + Console.WriteLine("-----------学生------------"); + student student1=new student(); + student1.Id = 10086; + student1.Name = "重阳割割"; + student1.Sex = '男'; + student1.Cardid = "22220000222013"; + student1.Tel = 110; + student1.Major = "土木工程"; + student1.Grade = "幼儿园大班"; + student1.way1(); + student1.way2(); + Console.WriteLine("----------教师------------"); + Teacher Teacher1=new Teacher(); + Teacher1.Id = 1314; + Teacher1.Name = "北大小磊"; + Teacher1.Sex = '男'; + Teacher1.Cardid = "6666666666666"; + Teacher1.Tel = 1314520; + Teacher1.Title = "二次元叫师"; + Teacher1.Wageno = "13214568778"; + Teacher1.way1(); + Teacher1.way3(); + //二、使用Wageno;类来描述游戏中的角色。 + //见英雄文件夹的图片。 + //分析1: 角色具有以下信息(简单数据) + //字段:角色名字,角色介绍,角色昵称,攻击力,防御力,速度。 + //方法:每个角色都有三个不同的攻击技能。 + //分析2:四个英雄的公共数据?公共数据向上抽取,抽象成一个Hero类,然后四个英雄继承这个Hero类,然后编写各自特有的类成员。 + Console.WriteLine("===========作业二============"); + skill skillone= new skill(); + skillone.rolename = "埃洛克"; + skillone.roleintroduce = "是一个废物英雄"; + skillone.roleid = 1; + skillone.attack = 80; + skillone.def = 50; + skillone.speed = 30; + skillone.skill1 = "碎石打击"; + skillone.skill2 = "烈焰钩"; + skillone.skill3 = "战斗咆哮"; + skill skilltwe=new skill(); + skilltwe.rolename = "泰拉"; + skilltwe.roleintroduce = "真的很low"; + skilltwe.roleid = 2; + skilltwe.attack = 80; + skilltwe.def = 50; + skilltwe.speed = 30; + skilltwe.skill1 = "巨烂冲击"; + skilltwe.skill2 = "元素突击"; + skilltwe.skill3 = "复仇杀戮"; + skill skillthere=new skill(); + skillthere.rolename = "卢卡斯"; + skillthere.roleintroduce = "废物啊"; + skillthere.roleid = 3; + skillthere.attack = 80; + skillthere.def = 30; + skillthere.speed = 60; + skillthere.skill1 = "减速冲击"; + skillthere.skill2 = "能量浪潮"; + skillthere.skill3 = "旋风剑舞"; + skill skillsi = new skill(); + skillsi.rolename = "洛菲"; + skillsi.roleintroduce = "很牛皮"; + skillsi.roleid = 4; + skillsi.attack = 999; + skillsi.def = 999; + skillsi.speed =999; + skillsi.skill1 = "能量精灵"; + skillsi.skill2 = "空间传送"; + skillsi.skill3 = "时空迸裂"; + skillone.print(); + Console.WriteLine("-------------------------"); + skilltwe.print(); + Console.WriteLine("-------------------------"); + skillthere.print(); + Console.WriteLine("-------------------------"); + skillsi.print(); + + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Teacher.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Teacher.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a938e8b79d680fafa608370ff0f795b6e8efefb --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Teacher.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏作业 +{ + internal class Teacher:person + { + //职称(Title)、工资号(Wageno) + public string Title; + public string Wageno; + public void way3() + { + Console.WriteLine("职称:{0}",Title); + Console.WriteLine("工资号;{0}",Wageno); + } + } + +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/person.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5813eeca4c5959d04c18de4f05c2c59d348712b7 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏作业 +{ + public class person + { + //编号(Id)、姓名(Name)、性别(Sex)、身份证号(Cardid)、联系方式(Tel) + public int Id { get; set; } + public string Name { get; set; } + public char Sex { get; set; } + public string Cardid { get; set; } + public int Tel { get; set; } + public void way1() + { + Console.WriteLine("编号:{0}",Id); + Console.WriteLine("姓名:{0}",Name); + Console.WriteLine("性别:{0}",Sex); + Console.WriteLine("省份证号;{0}",Cardid); + Console.WriteLine("联系方式:{0}",Tel); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/role.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..97b3fa20fa812a108d4f266d26b10c4ae405c623 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/role.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏作业 +{ + class role + { + //角色名字,角色介绍,角色昵称,攻击力,防御力,速度。 + public string rolename { get; set; } + public string roleintroduce { get; set; } + public int roleid { get; set; } + public int attack { get; set; } + public int def { get; set; } + public int speed { get; set; } + public string skill1 { get; set; } + public string skill2 { get; set; } + public string skill3 { get; set; } + + + + } +} + diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/skill.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/skill.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b04b4f97fbafea1938f05008d4280a2508b98a28 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/skill.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏作业 +{ + class skill:role + { + public void print() + { + Console.WriteLine("角色名称:{0}",rolename); + Console.WriteLine("角色介绍:{0}", roleintroduce); + Console.WriteLine("角色id:{0}", roleid); + Console.WriteLine("攻击力:{0}", attack); + Console.WriteLine("防御力:{0}", def); + Console.WriteLine("速度:{0}", speed); + Console.WriteLine("技能一:{0}", skill1); + Console.WriteLine("技能二:{0}", skill2); + Console.WriteLine("技能三:{0}", skill3); + + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/student.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5df4515cf39ec331d257c74da269218aa9bec925 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/student.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 游戏作业 +{ + internal class student:person + { + public string Major; + public string Grade; + public void way2() + { + + //专业(Major)、年级(Grade) + Console.WriteLine("专业:{0}",Major); + Console.WriteLine("年级:{0}",Grade); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Class1.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e067aae9d35eac4829492a08350cfaa1629cb42 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Class1.cs" @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1 + { + // 一、定义一个员工类 + public int Id { get; set; } + public string Name { get; set; } + public char Sex { get; set; } + public string Education { get; set; } + public string Info { get; set; } + public Class1(int id,string name,char sex,string education,string info) + { + this.Id = id; + this.Name = name; + this.Sex = sex; + this.Education = education; + this.Info = info; + } + public Class1() + { + Id = Id; + Name = Name; + Sex = Sex; + Education = Education; + Info = Info; + } + public void Print() + { + Console.WriteLine("工号:{0}",Id); + Console.WriteLine("姓名:{0}",Name); + Console.WriteLine("性别:{0}",Sex); + Console.WriteLine("学历:{0}",Education); + Console.WriteLine("部门信息:{0}",Info); + } +//1.定义字段,存放用户的工号、姓名、性别、学历和部门信息; +//2.定义属性封装字段 +//3.定义2个构造函数: +// 一个是无参构造函数,学历默认为专科; +// 一个有参构造函数,根据参数对类的属性进行初始化。 +//二、为之前作业中的学生类、用户类和图书类添加2个构造方法 +//1.一个无参的构造方法 +//2.一个有参的构造方法,根据参数对类的属性进行初始化 + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ec571398affc5a4acbae149f238cb5228f9529c1 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,15 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Class1 class1 = new Class1(1, "大果敌", '男',"本科","影视部"); + class1.Print(); + Class1 class2 = new Class1(); + Console.WriteLine("-----------"); + class2.Education = "专科"; + class2.Print(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/User.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e391bbc705951821e71f8a4792d34bc8896b959a --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/User.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 作业4 +{ + internal class User + { +//1.定义字段存放用户的账号、用户名和密码; + public string Account { get; set; } + public string Name { get; set; } + public string Password { get; set; } + //2.在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息; + public void way1() + { + Console.WriteLine("账号;{0}",Account); + Console.WriteLine("用户名:{0}", Name); + Console.WriteLine("密码:{0}",Password); + } +//3.在用户类中定义一个 登录身份辨认的方法:规则为用户名为“admin”和密码为“123456”时返回“管理员”,否则返回“普通用户”; + public void way2() + { + if (Name == "admin" && Password == "123456") + { + Console.WriteLine("登录身份为管理员"); + } + else + { + Console.WriteLine("登录身份为普通用户"); + } + } + public User(string Account,string Name,string Password) + { + this.Account = Account; + this.Name = Name; + this.Password= Password; + } + + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/library.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/library.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f6fd18a4887c8e35bf6c5f26f86b8fdd33ee66b3 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\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 作业4 +{ + internal class Library + { + private string bookid; + private string bookname; + private double title; + private string description; + private string author; + + public string BookId + { + get { return bookid; } + set { bookid = value; } + } + + public string BookName + { + get { return bookname; } + set { bookname = value; } + } + + public double Title + { + get { return title; } + set + { + if (value < 0) + { + title = 0; + } + else + { + title = value; + } + + } + } + + public string Description + { + get { return description; } + set { description = value; } + } + + public string Author + { + get { return author; } + set { author = value; } + } + public void PrintLib() + { + Console.WriteLine("图书编号 " + bookid); + Console.WriteLine("书名 " + bookname); + Console.WriteLine("价格 " + title); + Console.WriteLine("出版社 " + description); + Console.WriteLine("作者信息 " + author); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/student.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5d6861ccccf5c6da1460abe138e5cbb9a28ecea5 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/student.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 作业4 +{ + internal class student + { + // 二.定义一个学生类 + public int Id { get; set; } + public string Name { get;set; } + public char Sex { get;set; } + public int Age { get; set; } + public string Majorinfo { get; set; } + + //1.定义字段存放学生的学号、姓名、性别、年龄、专业信息; + //2.对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + + public void studentway() + { + Console.WriteLine("学号;{0}",Id); + Console.WriteLine("姓名;{0}",Name); + Console.WriteLine("性别;{0}",Sex); + if (Age > 128 && Age < 0) + { + Console.WriteLine(Age == 0); + } + else + { + Console.WriteLine("学生年龄;{0}",Age); + } + Console.WriteLine("专业信息;{0};",Majorinfo); + } +//3.在学生类中定义一个方法输出学生信息。 +//4. 在主方法实例化学生对象,赋值并输出 + + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Calculate.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Calculate.cs" new file mode 100644 index 0000000000000000000000000000000000000000..acf744e3b24dbe7e1f536b88c922fac67e40666e --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Calculate.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 控制台应用程序 +{ + internal class Calculate + { + protected int num1; + protected int num2; + public Calculate(int num1,int num2) + { + this.num1 =num1; + this.num2 =num2; + } + public virtual void DisplayResult() + { + Console.WriteLine("num1+num2={0}", num1 + num2); + Console.WriteLine("num1-num2={0}", num1 - num2); + Console.WriteLine("num1*num2={0}", num1 * num2); + Console.WriteLine("num1/num2={0}", num1 / num2); + } + + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c2b0003f2648d220ca3928a07d6dda5292d17a55 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,42 @@ +using 控制台应用程序; + +namespace 多态 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("请输入一个整数"); + int num1=Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("请输入一个整数"); + int num2 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("请输入一个操作符"); + string fu = Console.ReadLine(); + Calculate calculate = null; + + if (fu == "+") + { + calculate = new jiafa(num1, num2); + } + else if (fu == "-") + { + calculate = new jianfa(num1, num2); + } + else if (fu == "*") + { + calculate = new chengfa(num1, num2); + } + else if (fu == "/") + { + calculate = new chufa(num1, num2); + } + + } + + public static void Calculate(Calculate calculate) + { + calculate.DisplayResult(); + } + + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/jiafa.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/jiafa.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a3eeee2c6cfdf195895fae5fdb3bee402ba39d99 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\346\216\247\345\210\266\345\217\260\345\272\224\347\224\250\347\250\213\345\272\217\347\263\273\347\273\237/jiafa.cs" @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 控制台应用程序 +{ + internal class jiafa : Calculate + { + public jiafa(int num1, int num2) : base(num1, num2) + { + } + public override void DisplayResult() + { + Console.WriteLine("num1+num2={0}", num1 + num2); + } + } + internal class jianfa : Calculate + { + public jianfa(int num1, int num2) : base(num1, num2) + { + } + public override void DisplayResult() + { + Console.WriteLine("num1-num2={0}", num1 - num2); + } + } + internal class chengfa : Calculate + { + public chengfa(int num1, int num2) : base(num1, num2) + { + } + public override void DisplayResult() + { + Console.WriteLine("num1*num2={0}", num1 * num2); + } + } + internal class chufa : Calculate + { + public chufa(int num1, int num2) : base(num1, num2) + { + } + public override void DisplayResult() + { + Console.WriteLine("num1/num2={0}", num1 / num2); + } + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Count/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Count/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f50b46ac24ad9d7c2fb39a8e13e7b0d8932c3a34 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Count/Program.cs" @@ -0,0 +1,73 @@ +namespace Count +{ + internal class Program + { + static void Main(string[] args) + { + //一 + //1.循环遍历的方法 + //string text = "与其他面向对象语言一样,C# 语言也具有面向对象语言的基本特征,即封装、继承、 多态。封装:就是将代码看作一个整体,例如使用类、方法、接口等。在使用定义好的类、 方法、接口等对象时不必考虑其细节,只需要知道其对象名以及所需要的参数即可,也是一种提升代码安全性的方法。继承:是一种体现代码重用性的特性,减少代码的冗余,但在 C# 语言中仅支持单继承。多态:不仅体现了代码的重用性,也体现了代码的灵活性,它主要通过继承和实现接口的方式,让类或接口中的成员表现出不同的作用。"; + + //int CountClass = 0; + //int CountCode = 0; + + //foreach(char c in text) + //{ + // if (c == '类') + // { + // CountClass++; + // } + // else if (c == '码') + // { + // CountCode++; + // } + //} + + //Console.WriteLine($"类的个数:{CountClass}"); + //Console.WriteLine($"码的个数:{CountCode}"); + + //2.使用Replace方法 + //string text = "与其他面向对象语言一样,C# 语言也具有面向对象语言的基本特征,即封装、继承、 多态。封装:就是将代码看作一个整体,例如使用类、方法、接口等。在使用定义好的类、 方法、接口等对象时不必考虑其细节,只需要知道其对象名以及所需要的参数即可,也是一种提升代码安全性的方法。继承:是一种体现代码重用性的特性,减少代码的冗余,但在 C# 语言中仅支持单继承。多态:不仅体现了代码的重用性,也体现了代码的灵活性,它主要通过继承和实现接口的方式,让类或接口中的成员表现出不同的作用。"; + + //int countClass = text.Length - text.Replace("类","").Length; + //int countCode = text.Length - text.Replace("码", "").Length; + + //Console.WriteLine($"类的个数:{countClass}"); + //Console.WriteLine($"码的个数:{countCode}"); + + //3.使用Split()方法来实现 + //string text = "与其他面向对象语言一样,C# 语言也具有面向对象语言的基本特征,即封装、继承、 多态。封装:就是将代码看作一个整体,例如使用类、方法、接口等。在使用定义好的类、 方法、接口等对象时不必考虑其细节,只需要知道其对象名以及所需要的参数即可,也是一种提升代码安全性的方法。继承:是一种体现代码重用性的特性,减少代码的冗余,但在 C# 语言中仅支持单继承。多态:不仅体现了代码的重用性,也体现了代码的灵活性,它主要通过继承和实现接口的方式,让类或接口中的成员表现出不同的作用。"; + //string[] words = text.Split(' ', '、', ',', '。', ':', ';'); + + //int countClass = 0; + //int countCode = 0; + + //foreach (string c in words) + //{ + // if (c == "类") + // { + // countClass++; + // } + // else if (c == "码") + // { + // countCode++; + // } + + // Console.WriteLine(c); + //} + + //Console.WriteLine("类的个数: " + countClass); + //Console.WriteLine("码的个数: " + countCode); + + //二 + string text = "C# (英 文名为 CSharp) 是 微 软开发的一种 面向对 象的 编程 语言。C# 语言具备了面向对象 语言 的特 征, 即封装、继承、多态,并且添加了 事件和委托,增强了 编程的灵 活性。C# 语 言是 一种安全的、稳定的、简 单 的、面向对象的编程 语言 ,其语 法与 C++ 类似,但在编程过 程中要比 C++ 简单;它不仅去掉了 C++ 和 Java 语 言中的一些复杂特性,还提 供了可视化 工具,能够高效地 编写程序。C# 是运行 在.NE T平台之上的 编程 语言。"; + + int countSpace = text.Length - text.Replace(" ", "").Length; + string newText = text.Replace(" ", ""); + + Console.WriteLine("空格的个数" + countSpace); + Console.WriteLine(newText); + + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/DeBug/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/DeBug/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2236ce1d479dd2d7fe34b7033fd36e8e0218c5d0 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/DeBug/Program.cs" @@ -0,0 +1,117 @@ +namespace DeBug +{ + internal class Program + { + static void Main(string[] args) + { + //1.一个考试管理系统,需要录入考生成绩,只能录入数字,否则会报类型转换异常。 + //请编写相关代码, + //1、捕获FormatException异常,并打印输出“异常已处理; + //2、捕获OverflowException异常,数值超出double范围的异常,并打印输出“异常已处理; + //3、捕获一般异常Exception异常。 + //4、最终处理finally + //录入成绩结束后,请输出,总学生数,总分数,平均分。 + + int totalStudents = 0; + double totalScore = 0; + double averageScore = 0; + + try + { + while (true) + { + Console.Write("请输入学生的考试成绩(输入非数字结束录入):"); + string input = Console.ReadLine(); + + // 尝试将输入的字符串转换为 double 类型的成绩 + if (double.TryParse(input, out double score)) + { + totalStudents++; + totalScore += score; + } + else + { + break; // 输入非数字,结束录入 + } + } + + averageScore = totalScore / totalStudents; + } + catch (FormatException) + { + Console.WriteLine("异常已处理:输入的成绩格式不正确。"); + } + catch (OverflowException) + { + Console.WriteLine("异常已处理:输入的成绩超出范围。"); + } + catch (Exception ex) + { + Console.WriteLine("一般异常已处理:" + ex.Message); + } + finally + { + Console.WriteLine("录入成绩结束。"); + + Console.WriteLine("总学生数: " + totalStudents); + Console.WriteLine("总分数: " + totalScore); + Console.WriteLine("平均分: " + averageScore); + } + + //2.编写一个程序,用以接收用户输入的两个浮点型的数值,一个值表示用户想要存放在银行账户中金额,另一个值表示用户想要从银行账户中提取的金额。 + //实现存取款功能, + //用户功能选择:1、存款,2、取款 + //取款时: + //当用户想要提取的金额大于余额时,请手动抛出一个ArgumentOutOfRangeException 参数超出范围的异常,异常信息可以写“取款金额大于余额,请重新输入” + //,如此以确保取款金额始终不大于当前余额。 + //操作结束,打印输出余额是多少。 + //最后再添加catch一般异常 Exception,使得数据类型转换的异常也能被捕获到。 + + double balance = 0; + + try + { + Console.Write("请输入存款金额:"); + double depositAmount = GetValidAmountFromUser(); + + balance += depositAmount; + Console.WriteLine("存款成功!当前余额为:" + balance); + + Console.Write("请输入取款金额:"); + double withdrawAmount = GetValidAmountFromUser(); + + if (withdrawAmount > balance) + { + throw new ArgumentOutOfRangeException("取款金额大于余额,请重新输入"); + } + + balance -= withdrawAmount; + Console.WriteLine("取款成功!当前余额为:" + balance); + } + catch (ArgumentOutOfRangeException ex) + { + Console.WriteLine("异常已处理:" + ex.Message); + } + catch (Exception ex) + { + Console.WriteLine("一般异常已处理:" + ex.Message); + } + } + + static double GetValidAmountFromUser() + { + while (true) + { + string input = Console.ReadLine(); + if (double.TryParse(input, out double amount)) + { + return amount; + } + else + { + Console.Write("输入的金额无效,请重新输入:"); + } + } + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Animal.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f4176d273b717759dd6f220f150f5b039134070 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Animal.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal abstract class Animal + { + public abstract void Eat(); + + public virtual void Sleep() + { + Console.WriteLine("动物正在睡觉"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Cat.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Cat.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e91981784d1ec3493ab1a23cfee0a0456ef7b8a5 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Cat.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 Cat:Animal,IClimb + { + public override void Eat() + { + Console.WriteLine("小猫在吃鱼"); + } + + public void Climb() + { + Console.WriteLine("小猫会爬树"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Dog.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Dog.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bb989fb16155ba4f1a40e867aa635cb69d9c789f --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Dog.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 Dog:Animal,ISwim + { + public override void Eat() + { + Console.WriteLine("小狗正在吃骨头"); + } + + public void Swim() + { + Console.WriteLine("小狗会爬树"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Duck.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Duck.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5d2a7ef81764b94acc702ff6c9460abe9386d437 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/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,ISwim + { + public override void Eat() + { + Console.WriteLine("鸭子正在吃稻谷"); + } + + public void Swim() + { + Console.WriteLine("鸭子会游泳"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/IClimb.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/IClimb.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d39f872c71855c3e194f65dea9fa6d277b73ede3 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/IClimb.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal interface IClimb + { + void Climb(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/ISwim.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/ISwim.cs" new file mode 100644 index 0000000000000000000000000000000000000000..42ab9e4b9943e5ce7633a324aa8f2c2ac43a3e6e --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/ISwim.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Animal +{ + internal interface ISwim + { + void Swim(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Monkey.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Monkey.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c292c502766bd92ff739c0006d49859ce0e85a25 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Monkey.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 Monkey:Animal,IClimb + { + public override void Eat() + { + Console.WriteLine("小猴吃香蕉"); + } + public void Climb() + { + Console.WriteLine("小猴会爬树"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2947502f763df76e1af16162a77ac7cbbb1ef69c --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Animal/Program.cs" @@ -0,0 +1,24 @@ +namespace Animal +{ + internal class Program + { + static void Main(string[] args) + { + Dog dog = new Dog(); + dog.Eat(); + dog.Swim(); + Console.WriteLine("----------------"); + Duck duck = new Duck(); + duck.Eat(); + duck.Swim(); + Console.WriteLine("----------------"); + Cat cat = new Cat(); + cat.Eat(); + cat.Climb(); + Console.WriteLine("----------------"); + Monkey monkey = new Monkey(); + monkey.Eat(); + monkey.Climb(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Batmobile.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Batmobile.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0c0aa94859ad13639f1edaa7ce6b26b76f24f542 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Batmobile.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Batmobile +{ + internal class Batmobile:Car,IFly + { + public void Fly() + { + Console.WriteLine("Batmobile is flying!!!"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Car.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Car.cs" new file mode 100644 index 0000000000000000000000000000000000000000..04257638c778f02d70189135690985443eb11018 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Car.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Batmobile +{ + internal class Car + { + public string Brand { get; set; } + public void Run() + { + Console.WriteLine("Batmobile is running!!!"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/IFly.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/IFly.cs" new file mode 100644 index 0000000000000000000000000000000000000000..29b996f6bc4c60d1baf8a48f1d5270f508e907c1 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/IFly.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Batmobile +{ + internal interface IFly + { + void Fly(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4c84539e763ef878ed48f79d1644931c78666bd1 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Batmobile/Program.cs" @@ -0,0 +1,13 @@ +namespace Batmobile +{ + internal class Program + { + static void Main(string[] args) + { + Batmobile batmobile = new Batmobile(); + batmobile.Brand = "蝙蝠战车"; + batmobile.Run(); + batmobile.Fly(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Animal.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ffef67cbbb7f371a304bba58e712993ef02597ed --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Animal.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal abstract class Animal + { + public abstract void Eat(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Bird.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Bird.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9363a1eb985c4b087c9552a88eee9fd1d05a5104 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Bird.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal class Bird:Animal,ITakeOff,IFly,ILand + { + public override void Eat() + { + Console.WriteLine("早起的鸟儿有虫吃"); + } + + public void Layeggs() + { + Console.WriteLine("小鸟可以下蛋"); + } + + public void TakeOff() + { + Console.WriteLine("小鸟起飞"); + } + + public void Fly() + { + Console.WriteLine("小鸟飞行中"); + } + + public void Land() + { + Console.WriteLine("小鸟着陆了"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/IFly.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/IFly.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f63df627b3900b079265d30db35530ae82edcbb7 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/IFly.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal interface IFly + { + void Fly(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ILand.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ILand.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5460cd9e6f95b0fbe2711d040f06695affb339e9 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ILand.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal interface ILand + { + void Land(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ITakeOff.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ITakeOff.cs" new file mode 100644 index 0000000000000000000000000000000000000000..72f121432302df12de475ad2855ce381f5dfe44d --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/ITakeOff.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal interface ITakeOff + { + void TakeOff(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Plane.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Plane.cs" new file mode 100644 index 0000000000000000000000000000000000000000..464f59f9f5a5244cf9da9dc1535e78461d76adf4 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Plane.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal class Plane:Vehicle,ITakeOff,IFly,ILand + { + public override void Transport() + { + Console.WriteLine("飞机可以运输载人!!!"); + } + + public void TakeOff() + { + Console.WriteLine("飞机起飞"); + } + + public void Fly() + { + Console.WriteLine("飞机飞行中"); + } + + public void Land() + { + Console.WriteLine("飞机着陆了"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..72cab2c75efa41bb8a324ff60086f0c69cf6c9d9 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Program.cs" @@ -0,0 +1,27 @@ +namespace Every +{ + internal class Program + { + static void Main(string[] args) + { + Superman superman = new Superman(); + superman.Eat(); + superman.TakeOff(); + superman.Fly(); + superman.Land(); + Console.WriteLine(); + Bird bird = new Bird(); + bird.Eat(); + bird.TakeOff(); + bird.Fly(); + bird.Land(); + bird.Layeggs(); + Console.WriteLine(); + Plane plane = new Plane(); + plane.Transport(); + plane.TakeOff(); + plane.Fly(); + plane.Land(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Superman.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Superman.cs" new file mode 100644 index 0000000000000000000000000000000000000000..24ac8432063a4b857cce77cbc3c0d2fc1108f69a --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Superman.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal class Superman:Animal,ITakeOff,IFly,ILand + { + public override void Eat() + { + Console.WriteLine("超人也要吃东西"); + } + + public void TakeOff() + { + Console.WriteLine("超人起飞"); + } + + public void Fly() + { + Console.WriteLine("超人飞行中"); + } + + public void Land() + { + Console.WriteLine("超人着陆了"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Vehicle.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Vehicle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e809237e4c25c8772647afb990db847755cb6384 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Every/Vehicle.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Every +{ + internal abstract class Vehicle + { + public abstract void Transport(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/BlacksmithNPC.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/BlacksmithNPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0a81552b38df9dd1edad3af8e55c9c124796cce0 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/BlacksmithNPC.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NPC +{ + internal class BlacksmithNPC:NPC + { + public override void PerformAction() + { + Console.WriteLine("我是铁匠NPC,你可以来我这里锻造装备"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/MerchantNPC.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/MerchantNPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fa34cbd92a16a5a089505836c8057261ed4f1619 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/MerchantNPC.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NPC +{ + internal class MerchantNPC:NPC + { + public override void PerformAction() + { + Console.WriteLine("我是商贩NPC,你可以来我这里购买装备"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/NPC.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/NPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4572dfe06a9e181e52b57eda9fd179d1df6ab28e --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/NPC.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NPC +{ + internal abstract class NPC + { + public string name; + public string type; + + public void Talk() + { + Console.WriteLine("玩家你好,我是" + name + "我是一名" + type); + } + + public abstract void PerformAction(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..43aea27cdc54e11383b8162f5f5afed7286a1723 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/Program.cs" @@ -0,0 +1,27 @@ +namespace NPC +{ + internal class Program + { + static void Main(string[] args) + { + NPC[] npcs = new NPC[3]; + npcs[0] = new TaskNPC(); + npcs[0].name = "任务NPC"; + npcs[0].type = "任务"; + + npcs[1] = new MerchantNPC(); + npcs[1].name = "商贩NPC"; + npcs[1].type = "商贩"; + + npcs[2] = new BlacksmithNPC(); + npcs[2].name = "铁匠NPC"; + npcs[2].type = "铁匠"; + + foreach (NPC npc in npcs) + { + npc.Talk(); + npc.PerformAction(); + } + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/TaskNPC.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/TaskNPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dfb67317c503f3c1fc4c6c7a6ebc4710478b2c74 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/NPC/TaskNPC.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NPC +{ + internal class TaskNPC:NPC + { + public override void PerformAction() + { + Console.WriteLine("我是任务NPC,你可以接受我的任务"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/CookRobot.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/CookRobot.cs" new file mode 100644 index 0000000000000000000000000000000000000000..44d79e74808b119085a2c78337078271c3e6805f --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/CookRobot.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 抽象类作业 +{ + enum DishType + { + SichuanCuisine, + Hunan, + Cantonese, + MinCuisine, + SuCuisine, + ZhejiangCuisine, + HuiCuisine, + LuCuisine + }; + internal class CookRobot:Robot + { + public DishType dishType; + + public CookRobot(string name, DishType dishType) : base(name) + { + this.dishType = dishType; + } + + public override void Working() + { + Console.WriteLine(name+"正在炒菜,做的是"+dishType.ToString()); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/DeliveryRobot.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/DeliveryRobot.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b7d5b3fe2fec3a0de42b3b35341a1218bc743494 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/DeliveryRobot.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 抽象类作业 +{ + internal class DeliveryRobot:Robot + { + public int hours; + + public DeliveryRobot(string name, int hours) : base(name) + { + this.hours = hours; + } + + public override void Working() + { + Console.WriteLine(name + "正在传菜,已经工作了" + hours.ToString() + "小时"); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..04a12ea0fe1608820363b478e02311b1437f3d98 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Program.cs" @@ -0,0 +1,40 @@ +namespace 抽象类作业 +{ + internal class Program + { + public static Robot SelectRobot(string choice) + { + switch (choice) + { + case "炒菜": + return new CookRobot("炒菜机器人", DishType.SuCuisine); + //return new CookRobot(); + case "传菜": + return new DeliveryRobot("传菜机器人", 2); + //return new DeliveryRobot(); + default: + return null; + } + } + + public static void Main(string[] args) + { + Console.WriteLine("请输入您要选择的操作:(炒菜/传菜)"); + string choice = Console.ReadLine(); + + Robot robot = SelectRobot(choice); + + //robot.name = "robot1"; + //robot.Working(); + + if (robot != null) + { + robot.Working(); + } + else + { + Console.WriteLine("不支持该功能!"); + } + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Robot.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Robot.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5a32118ea0921a42ef06f51bd605228ee7f18eaf --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/Robot/Robot.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 抽象类作业 +{ + internal abstract class Robot + { + public string name; + + public Robot(string name) + { + this.name = name; + } + + public abstract void Working(); + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\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..e75dc5ee22f2351e32a9d36ba16a21b5a7448391 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,109 @@ +using System.Data; +using System.Data.SqlClient; + +namespace SQL_Server +{ + internal class Program + { + static void Main(string[] args) + { + //server = 服务器名称 / 数据库的实例名; uid = 登录名; pwd = 密码; database = 数据库名称 + string constor = "server=DESKTOP-R34AU67;uid=sa;pwd=123456;database=Library"; + + SqlConnection con = null; + + try + { + con = new SqlConnection(constor); + + SqlCommand cmd = new SqlCommand(); + + cmd.Connection = con; + + con.Open(); + + //添加 + cmd.CommandText = "insert into LibraryInfo(bookId,bookName) values(8,'朝花夕拾')"; + + int result = cmd.ExecuteNonQuery(); + + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result:{result}"); + Get(); + } + else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result:{result}"); + } + + //删除 + cmd.CommandText = "delete from LibraryInfo where bookId=7;"; + result = cmd.ExecuteNonQuery(); + + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result:{result}"); + + } + else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result:{result}"); + } + + //修改 + cmd.CommandText = "update LibraryInfo set bookName='呼兰河传' where bookId=3"; + result = cmd.ExecuteNonQuery(); + + if (result > 0) + { + Console.WriteLine($"执行{cmd.CommandText}语句成功,result:{result}"); + + } + else + { + Console.WriteLine($"执行{cmd.CommandText}语句失败,result:{result}"); + } + + } + catch (Exception ex) + { + Console.WriteLine("出现异常" + ex.Message); + } + finally + { + if (con != null) + { + con.Close(); + } + } + } + + public static void Get() + { + string constor = "server=DESKTOP-R34AU67;uid=sa;pwd=123456;database=Library"; + + string sql = "select * from LibraryInfo"; + + //1.创建数据库适配器 + SqlDataAdapter adapter = new SqlDataAdapter(sql, constor); + + //2.定义一个DataSet数据集对象,保存执行数据库查询后的结果集; + DataSet ds = new DataSet(); + + //3.Fill(集合对象):填充,将查询的结果集填充到集合对象中进行保存 + adapter.Fill(ds,"LibraryInfo"); + + //遍历行集合 + if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) + { + foreach(DataRow it in ds.Tables[0].Rows) + { + Console.WriteLine($"书本编号:{it[0]},书名:{it[1]}"); + } + } + } + + + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4ba5b3cbd3661494cabbe8f5964356351d47b3c2 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,42 @@ +namespace 动物继承 +{ + internal class Program + { + static void Main(string[] args) + { +//有四种动物,使用代码的继承关系来表示动物之间的关系 +//1.动物类:具有动物的共同属性:腿,重量等;共同行为:吃,叫,睡 +//2.猫科类:具有猫科动物的共同属性:胡须等,共同能力:夜视能力 +//3.鸟类:具有鸟类的共同行为:飞行 +//4.定义老虎、猫、老鹰、燕子四个子类,并且在这些子类中重写Animal 中吃和叫的方法 + laohu laohu = new laohu(); + laohu.name = "老虎"; + laohu.jiao = 4; + laohu.zhongliang= 5; + laohu.zhonglei = "猫科"; + laohu.gongtong = "夜视能力"; + laohu.way1(); + cat cat= new cat(); + cat.name = "猫"; + cat.jiao = 4; + cat.zhongliang = 5; + cat.zhonglei = "猫科"; + cat.gongtong = "夜视能力"; + cat.way1(); + niao niao = new niao(); + niao.name = "老鹰"; + niao.jiao = 2; + niao.zhongliang = 5; + niao.zhonglei = "鸟科"; + niao.gongtong = "飞行"; + niao.way1(); + yanzi yanzi= new yanzi(); + yanzi.name = "燕子"; + yanzi.jiao = 2; + yanzi.zhongliang = 5; + yanzi.zhonglei = "鸟类"; + yanzi.gongtong = "飞行"; + yanzi.way1(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/animal.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/animal.cs" new file mode 100644 index 0000000000000000000000000000000000000000..db3dab0715abac3f1597629c7ff865252b033bf0 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/animal.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物继承 +{ + internal class animal + { + public string name; + public int jiao; + public int zhongliang; + public string zhonglei; + public string gongtong; + public virtual void way1() + { + Console.WriteLine("动物名字:{0}", name); + Console.WriteLine("它的脚有几条:{0}", jiao); + Console.WriteLine("它的重量:{0}KG", zhongliang); + Console.WriteLine("它的种类:{0}", zhonglei); + Console.WriteLine("它的能力:{0}", gongtong); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/laohu.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/laohu.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d73a27737a2c3ff1825ea05585c908b3dd4b7aa2 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\212\250\347\211\251\347\263\273\347\273\237/laohu.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 动物继承 +{ + internal class laohu:animal + { + public override void way1() + { + Console.WriteLine("动物名字:{0}",name); + Console.WriteLine("它的脚有几条:{0}", jiao); + Console.WriteLine("它的重量:{0}KG", zhongliang); + Console.WriteLine("它的种类:{0}",zhonglei); + Console.WriteLine("它的能力:{0}",gongtong); + } + } + internal class cat : animal + { + public override void way1() + { + Console.WriteLine("动物名字:{0}", name); + Console.WriteLine("它的脚有几条:{0}", jiao); + Console.WriteLine("它的重量:{0}KG", zhongliang); + Console.WriteLine("它的种类:{0}", zhonglei); + Console.WriteLine("它的能力:{0}", gongtong); + } + } + internal class niao : animal + { + public override void way1() + { + Console.WriteLine("动物名字:{0}", name); + Console.WriteLine("它的脚有几条:{0}", jiao); + Console.WriteLine("它的重量:{0}KG", zhongliang); + Console.WriteLine("它的种类:{0}", zhonglei); + Console.WriteLine("它的能力:{0}", gongtong); + } + } + internal class yanzi : animal + { + public override void way1() + { + Console.WriteLine("动物名字:{0}", name); + Console.WriteLine("它的脚有几条:{0}", jiao); + Console.WriteLine("它的重量:{0}KG", zhongliang); + Console.WriteLine("它的种类:{0}", zhonglei); + Console.WriteLine("它的能力:{0}", gongtong); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..64c417e45580c78a039403944af9922b692f63e9 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/Program.cs" @@ -0,0 +1,43 @@ +using static 虚方法.chengxuyuan; + +namespace 虚方法 +{ + internal class Program + { + static void Main(string[] args) + { +//1.定义一个员工类,作为基类,包含姓名,性别,年龄等属性;包含一个方法代表工作的行为 + +//2.定义一个医生类,继承员工类,重写工作的方法,描述医生的具体工作 + +//3.定义一个程序员类,继承员工类,重写工作方法,描述程序员具体工作 + +//4.定义一个清洁工类,继承员工类,重写工作方法,描述清洁工的具体工作 + +//5.在主方法中为每个类实例化一个对象,用每个对象调用工作方法; + yisheng yisheng = new yisheng(); + yisheng.name = "林磊"; + yisheng.age= 1; + yisheng.mingzu = "汉"; + yisheng.gongzuo = "医生"; + yisheng.sex = "男"; + yisheng.way1(); + Console.WriteLine("------------------------------"); + chengxuyuan chengxuyuan = new chengxuyuan(); + chengxuyuan.name = "磊子"; + chengxuyuan.age = 3; + chengxuyuan.mingzu = "汉"; + chengxuyuan.gongzuo = "程序员"; + chengxuyuan.sex = "男"; + chengxuyuan.way1(); + Console.WriteLine("------------------------------"); + qingjiegong qingjiegong= new qingjiegong(); + qingjiegong.name = "木木垒"; + qingjiegong.age = 5; + qingjiegong.mingzu = "汉"; + qingjiegong.gongzuo = "清洁工"; + qingjiegong.sex = "女"; + qingjiegong.way1(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yisheng.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yisheng.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0428a25b0fd6be1fcc48cf248c9dcff5c91e3946 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yisheng.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 虚方法 +{ + internal class yisheng:yuangong + { + public override void way1() + { + Console.WriteLine("姓名:{0}", name); + Console.WriteLine("性别:{0}", sex); + Console.WriteLine("年龄:{0}", age); + Console.WriteLine("工作:{0}", gongzuo+"它的职责是帮助病人"); + Console.WriteLine("名族:{0}",mingzu); + } + } + internal class chengxuyuan:yuangong + { + public override void way1() + { + Console.WriteLine("姓名:{0}", name); + Console.WriteLine("性别:{0}", sex); + Console.WriteLine("年龄:{0}", age); + Console.WriteLine("工作:{0}", gongzuo+ "它的职责是修复代码"); + Console.WriteLine("名族:{0}", mingzu); + } + internal class qingjiegong:yuangong + { + public override void way1() + { + Console.WriteLine("姓名:{0}", name); + Console.WriteLine("性别:{0}", sex); + Console.WriteLine("年龄:{0}", age); + Console.WriteLine("工作:{0}", gongzuo+"它的职责是打扫卫生"); + Console.WriteLine("名族:{0}", mingzu); + } + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yuangong.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yuangong.cs" new file mode 100644 index 0000000000000000000000000000000000000000..75185e4b79b9bdc85c7a7a777dfb042248d2b5db --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\345\221\230\345\267\245\347\263\273\347\273\237/yuangong.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 虚方法 +{ + internal class yuangong + { + public string name;//姓名 + public string sex;//性别 + public int age;//年龄 + public string gongzuo;//工作 + public string mingzu;//名族 + public virtual void way1() + { + Console.WriteLine("姓名:{0}",name); + Console.WriteLine("性别:{0}",sex); + Console.WriteLine("年龄:{0}",age); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2637fca68af1f3692247b10d2a75fd0751f47088 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,34 @@ +namespace 作业4 +{ + internal class Program + { + static void Main(string[] args) + { + //4.在主方法中实例化用户类的对象,然后对其账号、用户名和密码赋值 + User user1= new User(); + user1.Account = "1"; + user1.Name= "admin"; + user1.Password= "123456"; + //5.在主方法中用实例化的对象调用方法,输出用户对象的信息和身份(管理员或者普通用户) + user1.way1(); + user1.way2(); + Console.WriteLine("---------------------"); + //4. 在主方法实例化学生对象,赋值并输出 + student student1 = new student(); + student1.Id = 122; + student1.Name = "小明"; + student1.Sex = '男'; + student1.Age = 20; + student1.Majorinfo = "软件技术"; + student1.studentway(); + Console.WriteLine("---------------------"); + Library library = new Library(); + library.BookId = "a12345"; + library.BookName = "Test"; + library.Title = 35; + library.Description = "aaa出版社"; + library.Author = "张三"; + library.PrintLib(); + } + } +} \ No newline at end of file diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ac1e10c2d292aa344612dfc321c76d4768f59e3b --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/User.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 作业4 +{ + internal class User + { +//1.定义字段存放用户的账号、用户名和密码; + public string Account { get; set; } + public string Name { get; set; } + public string Password { get; set; } + //2.在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息; + public void way1() + { + Console.WriteLine("账号;{0}",Account); + Console.WriteLine("用户名:{0}", Name); + Console.WriteLine("密码:{0}",Password); + } +//3.在用户类中定义一个 登录身份辨认的方法:规则为用户名为“admin”和密码为“123456”时返回“管理员”,否则返回“普通用户”; + public void way2() + { + if (Name == "admin" && Password == "123456") + { + Console.WriteLine("登录身份为管理员"); + } + else + { + Console.WriteLine("登录身份为普通用户"); + } + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/library.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/library.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f6fd18a4887c8e35bf6c5f26f86b8fdd33ee66b3 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\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 作业4 +{ + internal class Library + { + private string bookid; + private string bookname; + private double title; + private string description; + private string author; + + public string BookId + { + get { return bookid; } + set { bookid = value; } + } + + public string BookName + { + get { return bookname; } + set { bookname = value; } + } + + public double Title + { + get { return title; } + set + { + if (value < 0) + { + title = 0; + } + else + { + title = value; + } + + } + } + + public string Description + { + get { return description; } + set { description = value; } + } + + public string Author + { + get { return author; } + set { author = value; } + } + public void PrintLib() + { + Console.WriteLine("图书编号 " + bookid); + Console.WriteLine("书名 " + bookname); + Console.WriteLine("价格 " + title); + Console.WriteLine("出版社 " + description); + Console.WriteLine("作者信息 " + author); + } + } +} diff --git "a/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/student.cs" "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5d6861ccccf5c6da1460abe138e5cbb9a28ecea5 --- /dev/null +++ "b/11\350\277\236\345\242\236\351\222\261/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/student.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 作业4 +{ + internal class student + { + // 二.定义一个学生类 + public int Id { get; set; } + public string Name { get;set; } + public char Sex { get;set; } + public int Age { get; set; } + public string Majorinfo { get; set; } + + //1.定义字段存放学生的学号、姓名、性别、年龄、专业信息; + //2.对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + + public void studentway() + { + Console.WriteLine("学号;{0}",Id); + Console.WriteLine("姓名;{0}",Name); + Console.WriteLine("性别;{0}",Sex); + if (Age > 128 && Age < 0) + { + Console.WriteLine(Age == 0); + } + else + { + Console.WriteLine("学生年龄;{0}",Age); + } + Console.WriteLine("专业信息;{0};",Majorinfo); + } +//3.在学生类中定义一个方法输出学生信息。 +//4. 在主方法实例化学生对象,赋值并输出 + + } +} diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 9071656364fbec58c2e90bbb5365e6fe77af91df..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# 面向对象作业 - -#### Description -面向对象作业 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md deleted file mode 100644 index 4d91e821b569488b51c3acbccc8992479e707216..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# 面向对象作业 - -#### 介绍 -面向对象作业 - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)