diff --git "a/30\344\275\231\350\276\211/.keep" "b/30\344\275\231\350\276\211/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/01.md" "b/30\344\275\231\350\276\211/01.md" new file mode 100644 index 0000000000000000000000000000000000000000..3d0a9562627a159530d5bfd6f0aade5d59326f94 --- /dev/null +++ "b/30\344\275\231\350\276\211/01.md" @@ -0,0 +1,16 @@ +```csharp +namespace yh +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello, Welcome to my world!"); + Console.WriteLine("输出"); + Console.Write("不换行输出"); + // \n换行 \t空格 + } + } +} +``` + diff --git "a/30\344\275\231\350\276\211/02.md" "b/30\344\275\231\350\276\211/02.md" new file mode 100644 index 0000000000000000000000000000000000000000..69a9118b61ec85000ea78abaa472f323c8c5b1e5 --- /dev/null +++ "b/30\344\275\231\350\276\211/02.md" @@ -0,0 +1,316 @@ +作业 + +```c# +/*1.求圆的面积 +要求用户输入半径的值,打印出以此值为半径的圆的面积 +求圆的面积的公式:πr²。 +圆周率π定义成常量取3.14。 +r由用户输入并存入一个变量中此变量用double比较合适,因为用户可能会输入小数。*/ + + // Console.WriteLine("请输入圆的半径:"); + // double r = Convert.ToDouble(Console.ReadLine()); + // float pai = 3.14f; + // Console.WriteLine("圆的面积为" + pai * r * r); + // + // /*2.编写一个程序,请用户输入一个四位整数,将用户输入的四位数的千位、百位、十位和个位分别显示出来, + // * 如5632,则显示“用户输入的千位为5,百位为6,十位为3,个位为2”*/ + // Console.WriteLine("请输入一个四位数"); + // int number = int.Parse(Console.ReadLine()); + // int ge = number % 10; + // int shi = number / 10 % 10; + // int bai = number / 100 % 10; + // int qian = number / 1000; + // Console.WriteLine("个位数为" + ge); + // Console.WriteLine("十位数为" + shi); + // Console.WriteLine("百位数为" + bai); + // Console.WriteLine("千位数为" + qian); + // + // /*3.用户输入三个数,找出最大的数,打印输出。*/ + // + // Console.WriteLine("输入第一个数"); + // string x = Console.ReadLine(); + // int a = int.Parse(x); + // + // Console.WriteLine("请输入第二个数"); + // string y = Console.ReadLine(); + // int b = int.Parse(y); + // + // Console.WriteLine("请输入第三个数"); + // string z = Console.ReadLine(); + // int c = int.Parse(z); + // + // if (a > b) + // { + // if(a > c) + // { + // Console.WriteLine("最大值为" + a); + // } + // } + // else + // { + // if(b > c) + // { + // Console.WriteLine("最大值为" + b); + // } + // else + // { + // Console.WriteLine("最大值为" + c); + // } + // } + // + // //4.接受用户输入一个数n,求这个数的阶乘;5! = 5 * 4 * 3 * 2 * 1; + // Console.WriteLine("请输入一个数"); + // int li = int.Parse(Console.ReadLine());//接受输入 + // int lii = 1; + // for (; li > 0;) + // { + // //lii = li * lii; + // lii *= (li--); + // } + // Console.WriteLine(lii); + + //5.接受用户输入的一个数n,求n到1所有数的阶乘和;n!+ (n - 1)! + (n - 2)! +……+1! + // Console.WriteLine("请输入一个数"); + // int yi = int.Parse(Console.ReadLine()); + // int yii = 0; + // int yiii = 1; + // for (int i = 1; i <=yi ; i++) + // { + // yiii *= i; + // yii += yiii;//n*(前面的全部) 为阶层累加 + // } + // Console.WriteLine(yii); + //6.根据用户输入的菱形边长,打印菱形;如边长为3,行数为5; + + // Console.WriteLine("请输入一个整数边长以打印菱形:"); + // + // //定义n保存用户输入 + // int n = Int32.Parse(Console.ReadLine()); + // Console.WriteLine("边长为{0}实心菱形如下:", n); + // for (int i = 1; i < 2 * n; i++) + // { + // for (int j = 1; j < 2 * n; j++) + // { + // //满足以下条件的打印*,否则打印空格 + // if (i <= n && i + j == n + 1) + // { + // for (int l = 1; l <= i; l++) + // { + // Console.Write("* "); + // } + // } + // else if (i > n && i - j == n - 1) + // { + // for (int s = 1; s <= 2 * n - i; s++) + // { + // Console.Write("* "); + // } + // } + // else + // { + // Console.Write(" "); + // } + // } + // //打印一行后换行 + // Console.WriteLine(); + // } + + //7.用循环打印九九乘法表(用二维数组保存字符串后再打印) + + //Console.WriteLine("Hello World!"); + + //循环打印数组 + //for (int i = 1; i <= 9; i++) + //{ + // for (int j = 1; j <= 9; j++) + // { + // if (j <= i) + // { + // //打印一个,并且不换行(X为乘号,为了更加美观) + // Console.Write(i + "X" + j + "=" + i * j + "\t"); + // //要注意的是双引号引起来的都是String字符串类型,直接输出。String的“+”为拼接 + // } + // } + // //每一行打印完成后换行 + // Console.WriteLine(); + //} + ////打印完成 + //Console.ReadLine(); + + //8.输入一行字符串,分别统计出其中英文字母、数字、空格的个数。 + //string str = ""; + //int le = 0;//统计字母的数量 + //int sp = 4;//统计空格的数量 + //int num = 0; //统计数字的数量 + //int symbol = 5;//统计其它字符的数量 + //Console.Write("请输入一段字符:"); + //str = Console.ReadLine(); + //char[] c = str.ToCharArray();//把字符串转换成字符数组 + //foreach (char i in c) + //{ + // if (i >= 'a' && i <= 'z' || i >= 'A' && i <= 'Z') + // le++; + // else if (i >= '0' && i <= '9') + // num++; + // else if (i == ' ') + // sp++; + // else + // symbol++; + //} + //Console.WriteLine("字母有" + le + "个,空格有" + sp + "个,数字有" + num + "个,其它字符有" + symbol + "个."); + //Console.ReadLine(); + //9.在 Main 方法中创建一个 double 类型的数组,并在该数组中存入 5 名学生的考试成绩, + //计算总成绩和平均成绩。(要求使用foreach语句实现该功能) + double[] points = { 80, 88, 86, 90, 75.5 };//存入数组 + double sum = 0; + double avg = 0; + foreach (double point in points) + { + sum = sum + point; + } + avg = sum / points.Length; + Console.WriteLine("总成绩为:" + sum); + Console.WriteLine("平均成绩为:" + avg); + //10.定义一个方法,实现一维数组的排序功能,从大到小排序。(不要用Array类的方法) + //定义一个乱的数组 冒泡排序 + int[] arr = new int[] { 4, 5, 1, 2, 6, 9, 7, 3, 2 }; + //外循环 + for (int i = 0; i < arr.Length; i++) + { + //内循环 + for (int j = 0; j < arr.Length -1; j++) + { + //从大到小排序 + if (arr[i] < arr[j])// 相比较大的交换位置 + { + int temp; + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + //输出排序之后的数组 + for (int i = 0; i < arr.Length; i++) + { + Console.Write(arr[i] + " "); + } + Console.WriteLine(); + //11.实现查找数组元素索引的功能。定义一个数组,然后控制台输入要查找的元素, + //返回输入值在数组中最后一次出现的位置。若是找不到,请打印找不到。(不要用Array类的方法) + int[] frr = { 1,2,3,4,5,6,7,8,9}; + Console.WriteLine("数组元素有"); + for (int i = 0;i max) + //{ + // max = num2; + //} + //if (num3 > max) + //{ + // max = num3; + //} + //Console.WriteLine($"最大值是{max}"); + + //4.接受用户输入一个数n,求这个数的阶乘;5! = 5 * 4 * 3 * 2 * 1; + //Console.WriteLine("请输入一个数n:"); + //int n = Convert.ToInt32(Console.ReadLine()); + //int product = 1; + //for (int i = 1; i <= n; i++) + //{ + // product *= i; + //} + //Console.WriteLine($"{n}的阶乘是{product}"); + + //5.接受用户输入的一个数n,求n到1所有数的阶乘和;n!+(n-1!)+(n-2)!+……+1! + //Console.WriteLine("请输入一个数n:"); + //int n = Convert.ToInt32(Console.ReadLine()); + //int sum = 0; + //for(int i = n; i >= 1; i--) + //{ + // int prodocut = 1; + // for(int j = i; j >= 1; j--) + // { + // prodocut *= j; + // } + // sum += prodocut; + //} + //Console.WriteLine($"{n}-1的阶乘和是{sum}"); + + //6.根据用户输入的菱形边长,打印菱形;如边长为3,行数为5 + //Console.WriteLine("请输入菱形的边长:"); + //int n = Convert.ToInt32(Console.ReadLine()); + + //int mid = n / 2 + 1; //菱形中间行 + //int spacecount = mid - 1; //空格的数量 + //int starcount = 1; //星号的数量 + + ////打印上半部分菱形 + //for (int i = 1; i <= mid; i++) + //{ + // for (int j = 1; j <= spacecount; j++) + // { + // Console.Write(" "); + // } + + // for (int j = 1; j <= starcount; j++) + // { + // Console.Write("*"); + // } + + // Console.WriteLine(); + // spacecount--; + // starcount += 2; + //} + + //spacecount = 1; + //starcount = n - 2; //底部菱形的星号数量 + + ////打印下半部分菱形 + //for (int i = 1; i <= mid - 1; i++) + //{ + // for (int j = 1; j <= spacecount; j++) + // { + // Console.Write(" "); + // } + + // for (int j = 1; j <= starcount; j++) + // { + // Console.Write("*"); + // } + + // Console.WriteLine(); + // spacecount++; + // starcount -= 2; + //} + + //7.用循环打印九九乘法表(用二维数组保存字符串后再打印) + //string[,] table = new string[9, 9]; + //for (int i = 0; i < 9; i++) + //{ + // for (int j = 0; j < i + 1; j++) + // { + // table[i, j] = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1); + // // Console.Write(table[i, j].PadRight(10)); + // } + // // Console.WriteLine(); + //} + //for (int i = 0; i < 9; i++) + //{ + // for (int j = 0; j < i + 1; j++) + // { + // Console.Write(table[i, j].PadRight(10)); + // } + // Console.WriteLine(); + //} + + //8.用户输入正方形边长,用*打印出空心正方形 + //Console.WriteLine("请输入正方形的边长:"); + //int square=Convert.ToInt32(Console.ReadLine()); + //for (int i = 0; i < square; i++) + //{ + // for (int j = 0; j < square; j++) + // { + // if (i == 0 || i == square - 1 || j == 0 || j == square - 1) + // { + // Console.Write("* "); + // } + // else + // { + // Console.Write(" "); + // } + // } + // Console.WriteLine(); + //} + + //9.用户输入正方形边长,用*打印出实心正方形 + //Console.WriteLine("请输入正方形的边长:"); + //int square = Convert.ToInt32(Console.ReadLine()); + //for(int i = 0; i < square; i++) + //{ + // for(int j = 0; j < square; j++) + // { + // Console.Write("* "); + // } + // Console.WriteLine(); + //} + + //10.输入一行字符串,分别统计出其中英文字母、数字、空格的个数。 + //Console.WriteLine("请输入一行字符串:"); + //string str=Convert.ToString(Console.ReadLine()); + //int letter = 0; + //int digit = 0; + //int space = 0; + //foreach(char c in str) + //{ + // if (char.IsLetter(c)) + // { + // letter++; + // } + // else if (char.IsDigit(c)) + // { + // digit++; + // } + // else if (char.IsWhiteSpace(c)) + // { + // space++; + // } + //} + //Console.WriteLine($"英文字母个数为{letter},数字个数为{digit},空格个数为{space}"); + + //11.在 Main 方法中创建一个 double 类型的数组, + //并在该数组中存入 5 名学生的考试成绩, + //计算总成绩和平均成绩。(要求使用foreach语句实现该功能) + //double[] score = new double[5] { 66, 69, 22, 75, 86 }; + //double sum = 0; + //double avg = 0; + //foreach(double scores in score) + //{ + // sum += scores; + //} + //avg = sum / score.Length; + //Console.WriteLine($"总成绩是{sum},平均成绩是{avg}"); + + //12.定义一个方法,实现一维数组的排序功能,从大到小排序。(不要用Array类的方法) + //int[] a = { 10, 16, 98, 62, 45, 33, 11 }; + //for(int i = 0; i < a.Length; i++) + //{ + // for (int j = 0; j < a.Length - i - 1; j++) + // { + // if (a[j] > a[j + 1]) + // { + // int temp = a[j]; + // a[j] = a[j + 1]; + // a[j + 1] = temp; + // } + // } + //} + //Console.WriteLine("排序后的结果是:"); + //foreach(int b in a) + //{ + // Console.Write(b+" "); + //} + //Console.WriteLine(); + + //13.实现查找数组元素索引的功能。定义一个数组, + //然后控制台输入要查找的元素,返回输入值在数组中最后一次出现的位置。 + //若是找不到,请打印找不到。(不要用Array类的方法 + //int[] arr = new int[] { 1, 3, 5, 7, 3, 9, 2 }; + //Console.WriteLine("请输入要查找的元素:"); + //int target = Convert.ToInt32(Console.ReadLine()); + //int index = -1; + //for (int i = 0; i < arr.Length; i++) + //{ + // if (arr[i] == target) + // { + // index = i; + // } + //} + //if (index == -1) + //{ + // Console.WriteLine("找不到该元素"); + //} + //else + //{ + // Console.WriteLine("该元素最后一次出现的位置是:" + index); + //} + + //14.14.在 Main 方法中创建一个字符串类型的数组,并存入 5 个值, + //然后将数组中下标是偶数的元素输出。 + + //string[] str = { "aaa", "bbb", "ccc", "ddd", "eee", "fff" }; + //for(int i = 0; i < str.Length; i = i + 2) + //{ + // Console.WriteLine(str[i]); + //} + + //15.用二维数组存放数据,实现杨辉三角形的打印; + //定义一个二维数组来存储杨辉三角形的数据 + //int[][] yanghui = new int[10][]; + //for (int i = 0; i < 10; i++) + //{ + // yanghui[i] = new int[i + 1]; + //} + + ////计算杨辉三角形的数据 + //for (int i = 0; i < yanghui.Length; i++) + //{ + // for (int j = 0; j < yanghui[i].Length; j++) + // { + // if (j == 0 || j == i) + // { + // yanghui[i][j] = 1; + // } + // else + // { + // yanghui[i][j] = yanghui[i - 1][j - 1] + yanghui[i - 1][j]; + // } + // } + //} + + ////打印杨辉三角形 + //for (int i = 0; i < yanghui.Length; i++) + //{ + // for (int j = 0; j < yanghui[i].Length; j++) + // { + // Console.Write(yanghui[i][j] + " "); + // } + // Console.WriteLine(); + //} +``` + diff --git "a/30\344\275\231\350\276\211/04.md" "b/30\344\275\231\350\276\211/04.md" new file mode 100644 index 0000000000000000000000000000000000000000..4966f351d396a37802d5c753ba045b2d1ffd31cd --- /dev/null +++ "b/30\344\275\231\350\276\211/04.md" @@ -0,0 +1,151 @@ +主页代码 + +```c# +//1. 定义一个用户类,存放用户的账号、用户名和密码属性; + //在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息;然后在主方法调用输出; + Class1 class1= new Class1(); + + class1.id = 123456; + class1.name = "怡宝"; + class1.age = 19; + + class1.prointinfo(); + + // 2.定义一个学生类,存放学生的学号、姓名、性别、年龄、专业信息; + //对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + //在学生类中定义一个方法输出学生信息。 + //在主方法实例化对象,赋值并输出 + studentd studentd = new studentd(); //这个就是例化对象 + + studentd.id = 12345678; + studentd.name = "怡宝"; + studentd.sex = "女"; + studentd.Age = 18; + studentd.career = "前端编程大师"; + + studentd.studentdinof(); //这个是例化对象输出 + + //3.定义一个图书类,存放图书的编号、书名、价格、出版社、作者信息; + //对价格进行赋值限制,小于0价格,赋值为0 + //在图书类中定义一个方法输出图书信息; + //在主方法实例化对象,赋值并输出 + book book = new book(); + + book.id = 12345678; + book.name = "汉服"; + book.Price = 10000; + book.description = "新东方支持"; + book.information = "无"; + + book.bookinfo(); +``` + +第一个 + +```c# +//账号 + public int id; + //用户名 + public string name; + //密码 + public int age; + + + + public void prointinfo() + { + Console.WriteLine($"账号\t{id}"); + Console.WriteLine($"用户名\t{name}"); + Console.WriteLine($"密码\t{age}"); + } +``` + + + +第二个 + +```c# + //学号 + public int id; + //姓名 + public string name; //没有定义默认私有 + //性别 + public string sex; + //年龄 + public int age; + //专业信息 + public string career; + + public int Age //检测年龄 + { + set + { + if ( 0 <= value && value <=128) // valuye 代表传入给Age的值 + { + age = value; + } + else + { + age = 0; + } + } + get + { + return age; + } + } + + public void studentdinof() //定义一个方法输出学生信息 + { + Console.WriteLine($"学号\t{id}"); + Console.WriteLine($"姓名\t{name}"); + Console.WriteLine($"性别\t{sex}"); + Console.WriteLine($"年龄\t{age}"); + Console.WriteLine($"所学专业\t{career}"); + } +``` + + + +第三个 + +```# +//编号 + public int id; + //书名 + public string name; + //价格 + public int price; + //出版社 + public string description; + //作者信息 + public string information; + + public void bookinfo() + { + Console.WriteLine($"编号\t{id}"); + Console.WriteLine($"书名\t{name}"); + Console.WriteLine($"价格\t{price}"); + Console.WriteLine($"出版社\t{description}"); + Console.WriteLine($"作者信息\t{information}"); + } + + public int Price + { + set + { + if (value < 0) + { + price = 0; + } + else + { + price = value; + } + } + get + { + return price; + } +``` + diff --git "a/30\344\275\231\350\276\211/05.md" "b/30\344\275\231\350\276\211/05.md" new file mode 100644 index 0000000000000000000000000000000000000000..7fff270d833c022d31e4a4785b6385f8ac113b79 --- /dev/null +++ "b/30\344\275\231\350\276\211/05.md" @@ -0,0 +1,70 @@ +重载作业 + +主 + +```c# +mianji mianji1= new mianji(); + int a = 5; + int b = 7; + mianji1.yuan(a); + mianji1.yuan(a,b); + SumUtils ttp = new SumUtils(); + ttp.heihei(a,b);//整数相加 + double c = 2.5; + double d = 4.9; + ttp.heihei(c, d);//小数相加 + string e = "yyyyyyy"; + string f = "hhhhhhh"; + ttp.heihei(e,f);//字符串相加 + ttp.heihei(b); +``` + +类1 + +```c# + + //1. 定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 + //提示:计算圆的面积传半径,计算长方形面积传长和宽。 + public void yuan(int r) + { + Console.WriteLine("圆的面积是" + (3.14 * r * r)); + } + public void yuan(int a,int b) + { + Console.WriteLine("长方形的面积是" + a * b); + } +``` + +类2 + +```c# +//2.创建一个名为计算工具类 SumUtils,在类中定义4个方法:计算两个整数相加、两个小数相加、 + //两个字符串相加、以及从 1 到指定整数的和的方法。在 Main 方法中分别调用定义好的方法。 + + //提示:根据题目要求,分别定义 3 个带两个参数的方法,以及一个带一个整型参数的方法,四个方法名相同。 + public void heihei(int a,int b) + { + Console.WriteLine("整数相加" + (a +b)); + } + + public void heihei(double a, double b) + { + Console.WriteLine("小数相加" + (a + b)); + } + + public void heihei(string a, string b) + { + Console.WriteLine("字符串相加" + a + b); + } + + public void heihei(int a) + { + int c = 0; + for (int i = 1; i <= a; i++) + { + c += a; + } + Console.WriteLine("一直到" + a + "的整数和" + c); + } +``` + diff --git "a/30\344\275\231\350\276\211/06/.keep" "b/30\344\275\231\350\276\211/06/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/06/ArrayUtil.cs" "b/30\344\275\231\350\276\211/06/ArrayUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..92f7e277bb4e5dab25a330326c647274ba0413e9 --- /dev/null +++ "b/30\344\275\231\350\276\211/06/ArrayUtil.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态 +{ + internal class ArrayUtil + { + public static bool Isarray(T[] array) + { + return array == null || array.Length == 0; + } + } +} diff --git "a/30\344\275\231\350\276\211/06/Program.cs" "b/30\344\275\231\350\276\211/06/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e2840c3902903a128581b73b1215e45fc24952dc --- /dev/null +++ "b/30\344\275\231\350\276\211/06/Program.cs" @@ -0,0 +1,31 @@ +namespace 静态 +{ + internal class Program + { + static void Main(string[] args) + { + string str = ""; + Console.WriteLine(SrtringUtil.Istring(str)); + + int[] arr = { 1, 2, 3 }; + Console.WriteLine(ArrayUtil.Isarray(arr)); + + Student s1 = new Student("孙悟空"); + Student s2 = new Student("猪八戒"); + Student s3 = new Student("沙和尚"); + Student s4 = new Student("白龙马"); + s1.PrintStudent(); + s2.PrintStudent(); + s3.PrintStudent(); + s4.PrintStudent(); + + Console.WriteLine(); + + Student.ChangeTeacher("嫦娥姐姐"); + s1.PrintStudent(); + s2.PrintStudent(); + s3.PrintStudent(); + s4.PrintStudent(); + } + } +} \ No newline at end of file diff --git "a/30\344\275\231\350\276\211/06/SrtringUtil.cs" "b/30\344\275\231\350\276\211/06/SrtringUtil.cs" new file mode 100644 index 0000000000000000000000000000000000000000..943bc7986275324e011b1d13a94fc5654cfae2b7 --- /dev/null +++ "b/30\344\275\231\350\276\211/06/SrtringUtil.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态 +{ + internal class SrtringUtil + { + public static bool Istring(string str) + { + //IsNullOrEmpty方法 检查字符串是否为null或者空字符串 + //IsNullOrWhiteSpace方法 检查字符串是否为null或空字符串或仅有空字符组成 + //return string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value); + + + if (str == null || str == "") + { + return true; + } + char[] arrchar = str.ToCharArray(); + for (int i = 0; i < arrchar.Length; i++) + { + if (arrchar[i] != ' ') + { + return false; + } + + } + return true; + + } + } +} diff --git "a/30\344\275\231\350\276\211/06/Student.cs" "b/30\344\275\231\350\276\211/06/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..836850388c232aa601aa683cdba1d8af9645ad86 --- /dev/null +++ "b/30\344\275\231\350\276\211/06/Student.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 静态 +{ + internal class Student + { + private string name; + private static string teacher = "唐僧"; + public Student(string name) + { + this.name = name; + } + public void PrintStudent() + { + Console.WriteLine("大家好,我是{0},俺老师叫{1}",name,teacher); + } + + public static void ChangeTeacher(string newTeacher) + { + teacher = newTeacher; + } + } +} diff --git "a/30\344\275\231\350\276\211/07/.keep" "b/30\344\275\231\350\276\211/07/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/07/Program.cs" "b/30\344\275\231\350\276\211/07/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f2da57297cf91a9b6172f576cfd700daf5c31d6 --- /dev/null +++ "b/30\344\275\231\350\276\211/07/Program.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/30\344\275\231\350\276\211/08/.keep" "b/30\344\275\231\350\276\211/08/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/08/Hero.cs" "b/30\344\275\231\350\276\211/08/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4bc7b1f862e5633caa349902ef62c5e48d9c2eb4 --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Hero.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + internal class Hero + { + public string HeroName { get; set; } + public string jieshao { get; set; } + public string Name { get; set; } + public int attack { get; set; } + public int defense { get; set; } + public int speed { get; set; } + public void Print() + { + Console.WriteLine("角色名字:" + HeroName); + Console.WriteLine("角色介绍:" + jieshao); + Console.WriteLine("角色昵称:" + Name); + Console.WriteLine("攻击:" + attack); + Console.WriteLine("防御:" + defense); + Console.WriteLine("速度:" + speed); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Hero1.cs" "b/30\344\275\231\350\276\211/08/Hero1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..be02ff71fee6024c047000cf9951f889bcfb0e5a --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Hero1.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace 继承作业 +{/*在很多RPG游戏中,第一次打开游戏,都会先让你创建自己的“英雄”,或者自己要扮演的角色。这些英雄或者角色都是我们游戏中的“对象”,所以在开发的时候,我们需要针对每个角色都要写相应的类来描述。 +见英雄文件夹的图片。 +分析1:角色具有以下信息(简单数据) +字段:角色名字,角色介绍,角色昵称,攻击力,防御力,速度。 +方法:每个角色都有三个不同的攻击技能。 +分析2:四个英雄的公共数据?公共数据向上抽取,抽象成一个Hero类,然后四个英雄继承这个Hero类,然后编写各自特有的类成员。*/ + + internal class Hero1:Hero + { + /*public string HeroName { get; set; } + public string jieshao { get; set; } + public string Name { get; set; } + public int attack { get; set; } + public int defense { get; set; } + public int speed { get; set; } */ + public string jin1 { get; set; } + public string jin2 { get; set; } + public string jin3 { get; set; } + public Hero1() { } + public Hero1(string heroName, string jieshao, string name, int attack, int defense, int speed, string jin1,string jin2,string jin3) + { + this.jin1 = jin1; + this.jin2 = jin2; + this.jin3 = jin3; + } + public void Print() + { + base.Print(); + Console.WriteLine("技能一:"+jin1); + Console.WriteLine("技能二:" + jin2); + Console.WriteLine("技能三:" + jin3); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Hero2.cs" "b/30\344\275\231\350\276\211/08/Hero2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..59d489de7f1c68e64a5617d9a6056a93c07d4285 --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Hero2.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + internal class Hero2:Hero + { + public string jin1 { get; set; } + public string jin2 { get; set; } + public string jin3 { get; set; } + public Hero2() { } + public Hero2(string jin1, string jin2, string jin3) + { + this.jin1 = jin1; + this.jin2 = jin2; + this.jin3 = jin3; + } + public void Print() + { + base.Print(); + Console.WriteLine("技能一:" + jin1); + Console.WriteLine("技能二:" + jin2); + Console.WriteLine("技能三:" + jin3); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Hero3.cs" "b/30\344\275\231\350\276\211/08/Hero3.cs" new file mode 100644 index 0000000000000000000000000000000000000000..74178fa1a0e92f96b2929329dbee3933c6603c5e --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Hero3.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + internal class Hero3:Hero + { + public string jin1 { get; set; } + public string jin2 { get; set; } + public string jin3 { get; set; } + public Hero3() { } + public Hero3(string jin1, string jin2, string jin3) + { + this.jin1 = jin1; + this.jin2 = jin2; + this.jin3 = jin3; + } + public void Print() + { + base.Print(); + Console.WriteLine("技能一:" + jin1); + Console.WriteLine("技能二:" + jin2); + Console.WriteLine("技能三:" + jin3); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Hero4.cs" "b/30\344\275\231\350\276\211/08/Hero4.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a206803f9b5135d1c68495966d8ec9b24aceb68b --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Hero4.cs" @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + internal class Hero4:Hero + { + public string jin1 { get; set; } + public string jin2 { get; set; } + public string jin3 { get; set; } + public Hero4() { } + public Hero4(string jin1, string jin2, string jin3) + { + this.jin1 = jin1; + this.jin2 = jin2; + this.jin3 = jin3; + } + public void Print() + { + base.Print(); + Console.WriteLine("技能一:" + jin1); + Console.WriteLine("技能二:" + jin2); + Console.WriteLine("技能三:" + jin3); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Person.cs" "b/30\344\275\231\350\276\211/08/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1015089f6aac787625eb48a36581c08b910188a2 --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + //将student累和teacher累中共有的属性抽取出来定义一个一类person,然后student类和teacher类都继承这个共有属性类 + internal class Person + { + public int Id { get; set; } + public string Name { get; set; } + public string Sex { get; set; } + public string Cardid { get; set; } + public string Tel { get; set; } + public void Print() + { + Console.WriteLine("编号:" + Id); + Console.WriteLine("姓名:" + Name); + Console.WriteLine("性别:" + Sex); + Console.WriteLine("身份证号:" + Cardid); + Console.WriteLine("联系方式:" + Tel); + } + } +} diff --git "a/30\344\275\231\350\276\211/08/Program.cs" "b/30\344\275\231\350\276\211/08/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..63e63e8f51afc1a41021c866cd200bd3154e34c1 --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Program.cs" @@ -0,0 +1,88 @@ +using System.Net.WebSockets; + +namespace 继承作业 +{ + internal class Program + { + static void Main(string[] args) + { + //-----------------作业1------------------ + Console.WriteLine("-----------------作业1------------------"); + Console.WriteLine("学生信息:"); + Student student= new Student(); + student.Id= 1; + student.Name = "MOMO"; + student.Sex = "男"; + student.Cardid = "123456"; + student.Tel = "123456789"; + student.Major = "魔法师"; + student.Grade = "大一"; + student.Print(); + Console.WriteLine("------------------------------------------"); + Console.WriteLine("教师信息:"); + Teacher teacher = new Teacher(); + teacher.Id= 1; + teacher.Name = "河豚老师"; + teacher.Sex = "女"; + teacher.Cardid = "2233445566"; + teacher.Tel = "1122334455"; + teacher.Title = "年级主任"; + teacher.WageNo = "9290"; + teacher.Print(); + + //------------------作业2-------------------- + Console.WriteLine("-----------------作业2------------------"); + Console.WriteLine("*********英雄1*********"); + Hero1 hero1 = new Hero1(); + hero1.HeroName = "埃洛克"; + hero1.jieshao = "埃洛克是一名来自末日边境的勇士。他是圣约英雄中名副其实的拳术好手。他用毁灭性的符文魔法和无情的拳术攻击消灭敌人。"; + hero1.attack = 90; + hero1.defense = 50; + hero1.speed = 30; + hero1.Name = "黄焖鸡米饭"; + hero1.jin1 = "碎石打击"; + hero1.jin2 = "烈焰锚钩"; + hero1.jin3 = "战斗咆哮"; + hero1.Print(); + Console.WriteLine("----------------------------------------"); + Console.WriteLine("*********英雄2*********"); + Hero2 hero2 = new Hero2(); + hero2.HeroName = "泰拉"; + hero2.jieshao = "泰拉是为复仇而来的勇者。她挥舞法杖,将愤怒转化为强大的元素魔法和攻击力,因此战无不胜。"; + hero2.attack = 80; + hero2.defense = 60; + hero2.speed = 50; + hero2.Name = "番茄鸡蛋面"; + hero2.jin1 = "巨浪冲击"; + hero2.jin2 = "元素突击"; + hero2.jin3 = "复仇杀"; + hero2.Print(); + Console.WriteLine("----------------------------------------"); + Console.WriteLine("*********英雄3*********"); + Hero3 hero3 = new Hero3(); + hero3.HeroName = "卢卡斯"; + hero3.jieshao = "卢卡斯是一名彬彬有礼的剑客,能控制源质能量。他一手持剑战斗,另一手辅助攻击。"; + hero3.attack = 80; + hero3.defense = 40; + hero3.speed = 50; + hero3.Name = "七彩鸡米线"; + hero3.jin1 = "减速陷阱"; + hero3.jin2 = "能量浪潮"; + hero3.jin3 = "旋风剑舞"; + hero3.Print(); + Console.WriteLine("----------------------------------------"); + Console.WriteLine("*********英雄4*********"); + Hero4 hero4 = new Hero4(); + hero4.HeroName = "洛菲"; + hero4.jieshao = "洛菲是一名攻击迅猛且擅长传送魔法的时空旅行者,喜欢利用她的幻象伙伴迷惑、吸引并摧毁敌人。"; + hero4.attack = 70; + hero4.defense = 30; + hero4.speed = 80; + hero4.Name = "朝鲜冷面"; + hero4.jin1 = "能量精灵"; + hero4.jin2 = "暗影传送"; + hero4.jin3 = "时空迸裂"; + hero4.Print(); + } + } +} \ No newline at end of file diff --git "a/30\344\275\231\350\276\211/08/Student.cs" "b/30\344\275\231\350\276\211/08/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..82529a1fac3df300bd1e9425dbc447fb09bf110b --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Student.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + /*一、 假设要完成一个学校的校园管理信息系统,在员工管理系统中有不同的人员信息,包括学生信息、教师信息等。 +学生的字段:编号(Id)、姓名(Name)、性别(Sex)、身份证号(Cardid)、联系方式(Tel)、专业(Major)、年级(Grade) +教师的字段:编号(Id)、姓名(Name),性别 (Sex)、身份证号(Cardid)、联系方式(Tel)、职称(Title)、工资号(Wageno)*/ + + internal class Student:Person + { + /* public int Id { get; set; } + public string Name { get; set; } + public string Sex { get; set; } + public string Cardid { get; set; } + public string Tel { get; set; } */ + public string Major { get; set; } + public string Grade { get; set; } + public Student() { } + public Student(int id,string name,string sex,string cardid,string tel,string major, string grade) + { + Major = major; + Grade = grade; + } + public void Print() + { + /* Console.WriteLine("编号:" + Id); + Console.WriteLine("姓名:" + Name); + Console.WriteLine("性别:" + Sex); + Console.WriteLine("身份证号:" + Cardid); + Console.WriteLine("联系方式:" + Tel); */ + base.Print(); + Console.WriteLine("专业:" + Major); + Console.WriteLine("年级:" + Grade); + } + + } + +} diff --git "a/30\344\275\231\350\276\211/08/Teacher.cs" "b/30\344\275\231\350\276\211/08/Teacher.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5f11b7bcc11bbac28fcbfd4e22334535a41dd036 --- /dev/null +++ "b/30\344\275\231\350\276\211/08/Teacher.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 继承作业 +{ + internal class Teacher:Person + { + /* public int Id { get; set; } + public string Name { get; set; } + public string Sex { get; set; } + public string Cardid { get; set; } + public string Tel { get; set; } */ + public string Title { get; set; } + public string WageNo { get; set; } + public void Print() + { + /* Console.WriteLine("编号:" + Id); + Console.WriteLine("姓名:" + Name); + Console.WriteLine("性别:" + Sex); + Console.WriteLine("身份证号:" + Cardid); + Console.WriteLine("联系方式:" + Tel); */ + base.Print(); + Console.WriteLine("职称:" + Title); + Console.WriteLine("工资号:" + WageNo); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/.keep" "b/30\344\275\231\350\276\211/09/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/09/Class1.cs" "b/30\344\275\231\350\276\211/09/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3f8477c783972b696daf56290a2c888801ad282e --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class1.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1 + { + //一、 雇员系统,定义雇员基类,共同的属性,姓名、地址和出生日期(可有可无), + //子类:程序员,秘书,高层管理,清洁工,他们有不同的工资算法, + //其中高级主管和程序员采用底薪加提成的方式, + //高级主管和程序员的底薪分别是5000元和2000元 , + //秘书和清洁工采用工资的方式,工资分别是3000和1000, + public string nmae; + public string dizhi; + public void a1(int b) + { + //程序员 + Console.WriteLine("名字是 " + nmae + "地址是 " + dizhi); + Console.WriteLine("程序员工资是" + (2000 + 100*b)); + } + public void a2(int b) + { + //高级主管 + Console.WriteLine("名字是 " + nmae + "地址是 " + dizhi); + Console.WriteLine("高级主管工作是" + (5000 + 20*b)); + } + public void a3() + { + //秘书 + Console.WriteLine("名字是 " + nmae + "地址是 " + dizhi); + Console.WriteLine("秘书工资是" + 3000); + } + public void a4() + { + //清洁工 + Console.WriteLine("名字是 " + nmae + "地址是 " + dizhi); + Console.WriteLine("清洁工工资是" + 2000); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class2-1.cs" "b/30\344\275\231\350\276\211/09/Class2-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c067daf3c81e48e80799a41e4119c9e6047a593b --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class2-1.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_1:Class2 + { + //专科生 + public string spec; + public void C2_1() + { + Console.WriteLine("姓名 " + name + " 年龄 "+ age + " 学位 " + degree +" 专科 专业 " + spec); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class2-2.cs" "b/30\344\275\231\350\276\211/09/Class2-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2056aa80406583d6208736cd43041574e45c40e3 --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class2-2.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_2:Class2 + { + //本科生 + public string drec; + public void C2_2() + { + Console.WriteLine("姓名 " + name + " 年龄 " + age + " 学位 " + degree + " 本科 研究方向" + drec); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class2.cs" "b/30\344\275\231\350\276\211/09/Class2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f00b9cc2afb2c4b578022343ea83357167a423fc --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class2.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2 + { + //设计一个学生类Student, + //包括的属性有姓名name,年龄age,学位degree。 + //由学生类Student + //派生出专科生类Specialty和本科生类Undergraduate + //专科生类包含的属性有专业spec, + //本科生类包括的属性有研究方向drec。 + //每个类都有相关数据的输出方法。最后在一个测试类中对设计的类进行测试。 + //要求测试结果如下: + //姓名:王雷 年龄:17 学位:专科 专业:java + //姓名:刘文 年龄:22 学位:本科 研究方向:网络技术 + public string name; + public int age; + public string degree; + } +} diff --git "a/30\344\275\231\350\276\211/09/Class3.cs" "b/30\344\275\231\350\276\211/09/Class3.cs" new file mode 100644 index 0000000000000000000000000000000000000000..46edd172c2b64ef49e71a9b27d0901d332ec6a95 --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class3.cs" @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class3 + { + //求周长,面积(三角形, 四边形, 圆形) + public void sanjiaoxing(double a,double b,double c) + { + double p = (a+b+c)/2; + double triangleArea = Math.Sqrt(p * (p - a) * (p - b) * (p - c)); + double trianglePerimeter = a + b + c; + Console.WriteLine($"三角形的面积为 {triangleArea:F2},周长为 {trianglePerimeter:F2}"); + } + + public void shibianxing(double side1, double side2, double side3,double side4) + { + double quadrilateralPerimeter = side1 + side2 + side3 + side4; + double quadrilateralArea = 0; + + if (side1 == side2 && side2 == side3 && side3 == side4) + { + quadrilateralArea = side1 * side2; + } + else + { + double s1 = (side1 + side2 + side3) / 2; + double s2 = (side3 + side4 + side1) / 2; + double area1 = Math.Sqrt(s1 * (s1 - side1) * (s1 - side2) * (s1 - side3)); + double area2 = Math.Sqrt(s2 * (s2 - side3) * (s2 - side4) * (s2 - side1)); + quadrilateralArea = area1 + area2; + } + + Console.WriteLine($"四边形的面积为 {quadrilateralArea:F2},周长为 {quadrilateralPerimeter:F2}"); + } + + public void yuanxing(double a) + { + if (a >= 0) + { + Console.WriteLine("周长为 " + (3.14 * 2 * a) + " 面积为 " + (3.14 * a * a)); + } + else + { + Console.WriteLine( "输入有误"); + } + + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class4.cs" "b/30\344\275\231\350\276\211/09/Class4.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0b675d69421641a0f113c79636d7c0ade1c61eac --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class4.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class4 + { + //字段:姓名,工作年限,月薪、 + //组长(GroupLeader): 月薪+1000*年限 + //经理(Manager) :月薪+1000*年限* 基础分红;需要增加一个 字段:基础分红1000 + //客户经理(AccountManager):月薪+1000*年限* 分红(基础分红*3) + //求组长,经理的年薪。 + public string name; + public int age; + public int yx; + + public int fh; + public void zhuzhang() + { + //组长年薪 + Console.WriteLine("组长的年薪为 " + (yx + 1000*age)*12); + } + public void jingli() + { + //经理的年薪 + Console.WriteLine("经理的年薪" + (yx + 1000*age + fh)*12); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class5-1.cs" "b/30\344\275\231\350\276\211/09/Class5-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b509e3b9cb3ad2c4a7f7c5125009e7af4005ceb4 --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class5-1.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class5_1:Class5 + { + //小车类Car是Vehicle的子类,其中包含的属性有载人数loader。 + public int loader; + public void class5() + { + Console.WriteLine("汽车品牌 " + brand + " 车轮个数 " + wheels + " 车重 " + weight + " 载人数 " + loader); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class5-2.cs" "b/30\344\275\231\350\276\211/09/Class5-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bd06fb1e6059a4e8738f75421a4178f5202b8d9c --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class5-2.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class5_2:Class5_1 + { + //卡车类Truck是Car类的子类,其中包含的属性有载重量payload。 + public double payload; + public void class5() + { + Console.WriteLine("汽车品牌 " + brand + " 车轮个数 " + wheels + " 车重 " + weight + " 载人数 " + loader + " 搬运重量 " + payload); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Class5.cs" "b/30\344\275\231\350\276\211/09/Class5.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c3ab46cd90c1d61656881e79acc861dd2fe10c85 --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Class5.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class5 + { + //五、 设计一个汽车类Vehicle,包含的属性有汽车品牌brand、车轮个数wheels和车重weight。 + //小车类Car是Vehicle的子类,其中包含的属性有载人数loader。 + //卡车类Truck是Car类的子类,其中包含的属性有载重量payload。 + //每个类都有构造方法和输出相关数据的方法。 + public string brand; + public int wheels; + public int weight; + + public void class5() + { + Console.WriteLine("汽车品牌 " + brand + " 车轮个数 " + wheels + " 车重 " + weight); + } + } +} diff --git "a/30\344\275\231\350\276\211/09/Program.cs" "b/30\344\275\231\350\276\211/09/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..29dd71ef123b8236df0760cf972135b18fd6080f --- /dev/null +++ "b/30\344\275\231\350\276\211/09/Program.cs" @@ -0,0 +1,137 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("------------作业1-----------"); + Class1 b1 = new Class1(); + { + //程序员 + b1.nmae = "b1"; + b1.dizhi = "北京"; + } + b1.a1(10); + + Class1 b2 = new Class1(); + { + //高级主管 + b2.nmae = "b2"; + b2.dizhi = "北京"; + } + b2.a2(30); + + Class1 b3 = new Class1(); + { + b3.nmae = "b3"; + b3.dizhi = "北京"; + } + b3.a3(); + + Class1 b4 = new Class1(); + { + b4.nmae = "b4"; + b4.dizhi = "北京"; + } + b4.a4(); + Console.WriteLine("------------作业2-----------"); + Class2_1 class2_1 = new Class2_1(); + { + class2_1.name = "王雷"; + class2_1.age = 17; + class2_1.degree = "专科"; + class2_1.spec = "java"; + } + class2_1.C2_1(); + + Class2_2 class2_2 = new Class2_2(); + { + class2_2.name = "刘文"; + class2_2.age = 22; + class2_2.degree = "本科"; + class2_2.drec = "网络技术"; + } + class2_2.C2_2(); + Console.WriteLine("------------作业3-----------"); + sanjiaoxing(4.0,5.0,7.0); + shibianxing(5,6,7,8); + yuanxing(5); + Console.WriteLine("------------作业4-----------"); + Class4 class4_1 = new Class4(); + { + class4_1.name = "组长"; + class4_1.age = 12; + class4_1.yx = 2000; + } + class4_1.zhuzhang(); + Class4 class4_2 = new Class4(); + { + class4_2.name = "经理"; + class4_2.age = 12; + class4_2.yx = 5000; + class4_2.fh = 1000; + } + class4_2.jingli(); + Console.WriteLine("------------作业5-----------"); + Class5_1 class5_1 = new Class5_1(); + { + class5_1.brand = "小车"; + class5_1.wheels = 4; + class5_1.weight = 300; + class5_1.loader = 500; + } + class5_1.class5(); + Class5_2 class5_2 = new Class5_2(); + { + class5_2.brand = "大车"; + class5_2.wheels = 14; + class5_2.weight = 3100; + class5_2.loader = 1500; + class5_2.payload = 4000; + } + class5_2.class5(); + } + //求周长,面积(三角形, 四边形, 圆形) + public static void sanjiaoxing(double a, double b, double c) + { + double p = (a + b + c) / 2; + double triangleArea = Math.Sqrt(p * (p - a) * (p - b) * (p - c)); + double trianglePerimeter = a + b + c; + Console.WriteLine($"三角形的面积为 {triangleArea:F2},周长为 {trianglePerimeter:F2}"); + } + + public static void shibianxing(double side1, double side2, double side3, double side4) + { + double quadrilateralPerimeter = side1 + side2 + side3 + side4; + double quadrilateralArea = 0; + + if (side1 == side2 && side2 == side3 && side3 == side4) + { + quadrilateralArea = side1 * side2; + } + else + { + double s1 = (side1 + side2 + side3) / 2; + double s2 = (side3 + side4 + side1) / 2; + double area1 = Math.Sqrt(s1 * (s1 - side1) * (s1 - side2) * (s1 - side3)); + double area2 = Math.Sqrt(s2 * (s2 - side3) * (s2 - side4) * (s2 - side1)); + quadrilateralArea = area1 + area2; + } + + Console.WriteLine($"四边形的面积为 {quadrilateralArea:F2},周长为 {quadrilateralPerimeter:F2}"); + } + + public static void yuanxing(double a) + { + if (a >= 0) + { + Console.WriteLine("周长为 " + (3.14 * 2 * a) + " 面积为 " + (3.14 * a * a)); + } + else + { + Console.WriteLine("输入有误"); + } + + } + } +} \ No newline at end of file diff --git "a/30\344\275\231\350\276\211/10/.keep" "b/30\344\275\231\350\276\211/10/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/10/Class1-1.cs" "b/30\344\275\231\350\276\211/10/Class1-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..90372ba7b757c6120ebe2fb7a94364cf9e94bc76 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class1-1.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1_1:Class1 + { + //2.定义一个医生类,继承员工类,重写工作的方法,描述医生的具体工作 + public override void yisheng() + { + base.yisheng(); + Console.WriteLine("本医生会飞"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class1-2.cs" "b/30\344\275\231\350\276\211/10/Class1-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..df11dc396f3234438eeba094c89cadb29b60d4ac --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class1-2.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1_2:Class1 + { + //3. 定义一个程序员类,继承员工类,重写工作方法,描述程序员具体工作 + public override void chengxuyuan() + { + base.chengxuyuan(); + Console.WriteLine("我是程序员我也会飞"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class1-3.cs" "b/30\344\275\231\350\276\211/10/Class1-3.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ca22846fa5ae596ec39f50fe458699b9af2382d8 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class1-3.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1_3:Class1 + { + //4. 定义一个清洁工类,继承员工类,重写工作方法,描述清洁工的具体工作 + public override void qingjieguang() + { + base.qingjieguang(); + Console.WriteLine("我是清洁工我和它们一样会飞"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class1.cs" "b/30\344\275\231\350\276\211/10/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..df758cf1b19f1e96710d10be8bc0355134c61eb6 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class1.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1 { + + //1. 定义一个员工类,作为基类,包含姓名,性别,年龄等属性;包含一个方法代表工作的行为 + public string name; + public string xingbie; + public int age; + public virtual void yisheng() + { + Console.WriteLine("我是医生"); + } + public virtual void chengxuyuan() + { + Console.WriteLine("我是程序员"); + } + public virtual void qingjieguang() + { + Console.WriteLine("我是清洁工"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-1-1.cs" "b/30\344\275\231\350\276\211/10/Class2-1-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..499e1faaefba42ecd3d7cd1090eb232f81ce2855 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-1-1.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_1_1:Class2_1 + { + //老虎 + public override void chi() + { + base.chi(); + Console.WriteLine("老虎吃"); + } + public override void jiao() + { + base.jiao(); + Console.WriteLine("老虎叫"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-1-2.cs" "b/30\344\275\231\350\276\211/10/Class2-1-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..05133a63d6af8a57a209776f51ff65700f60b097 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-1-2.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_1_2:Class2_1 + { + //猫 + public override void chi() + { + base.chi(); + Console.WriteLine("猫吃"); + } + public override void jiao() + { + base.jiao(); + Console.WriteLine("猫叫"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-1.cs" "b/30\344\275\231\350\276\211/10/Class2-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..84670f4fd1b9980723c2f69040bd6cfc8baeb634 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-1.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_1:Class2 + { + //2. 猫科类:具有猫科动物的共同属性:胡须等,共同能力:夜视能力 + public string huxv; + public virtual void yeshi() + { + Console.WriteLine("我他妈会夜视"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-2-1.cs" "b/30\344\275\231\350\276\211/10/Class2-2-1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8578b64f7449810aefb2c3d704c61798b14f402f --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-2-1.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_2_1:Class2_2 + { + //老鹰 + public override void chi() + { + base.chi(); + Console.WriteLine("老鹰吃"); + } + public override void jiao() + { + base.jiao(); + Console.WriteLine("老鹰叫"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-2-2.cs" "b/30\344\275\231\350\276\211/10/Class2-2-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..112643308613c88c6f30b4e145be0bd42d200821 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-2-2.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_2_2:Class2_2 + { + //燕子 + public override void chi() + { + base.chi(); + Console.WriteLine("燕子吃"); + } + public override void jiao() + { + base.jiao(); + Console.WriteLine("燕子叫"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2-2.cs" "b/30\344\275\231\350\276\211/10/Class2-2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..60d9de6b82e7dd5e059c016ee14dfb5f181d0ebd --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2-2.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2_2:Class2 + { + //3. 鸟类:具有鸟类的共同行为:飞行 + public virtual void feixing() + { + Console.WriteLine("我踏马会飞"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Class2.cs" "b/30\344\275\231\350\276\211/10/Class2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9a7f5f24d2e849dd2a87cf9497f17ef1eec92499 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Class2.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2 + { + //1. 动物类:具有动物的共同属性:腿,重量等;共同行为:吃,叫,睡 + public string tui; + public int zhuangliang; + public virtual void chi() + { + Console.WriteLine("吃"); + } + public virtual void jiao() + { + Console.WriteLine("叫"); + } + public virtual void shui() + { + Console.WriteLine("睡"); + } + } +} diff --git "a/30\344\275\231\350\276\211/10/Program.cs" "b/30\344\275\231\350\276\211/10/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3cb6e0afb51240c5846f4188794194fedc74a742 --- /dev/null +++ "b/30\344\275\231\350\276\211/10/Program.cs" @@ -0,0 +1,46 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + //杨辉三角 杨辉 = new 杨辉三角(); + //杨辉.aa(); + Console.WriteLine("--------------第一题----------"); + Class1_1 class1_1 = new Class1_1(); + { + class1_1.name = "医生"; + class1_1.xingbie = "男"; + class1_1.age= 1; + } + class1_1.yisheng(); + Class1_2 class1_2 = new Class1_2(); + { + class1_1.name = "程序员"; + class1_1.xingbie = "男"; + class1_1.age = 1; + } + class1_2.chengxuyuan(); + Class1_3 class1_3 = new Class1_3(); + { + class1_1.name = "清洁工"; + class1_1.xingbie = "男"; + class1_1.age = 1; + } + class1_3.qingjieguang(); + Console.WriteLine("--------------第2题----------"); + Class2_1_1 class2_1_1 = new Class2_1_1(); + class2_1_1.chi(); + class2_1_1.jiao(); + Class2_1_2 class2_1_2 = new Class2_1_2(); + class2_1_2.chi(); + class2_1_2.jiao(); + Class2_2_1 class2_2_1 = new Class2_2_1(); + class2_2_1.chi(); + class2_2_1.jiao(); + Class2_2_2 class2_2_2 = new Class2_2_2(); + class2_2_2.chi(); + class2_2_2.jiao(); + } + } +} \ No newline at end of file diff --git "a/30\344\275\231\350\276\211/10/\346\235\250\350\276\211\344\270\211\350\247\222.cs" "b/30\344\275\231\350\276\211/10/\346\235\250\350\276\211\344\270\211\350\247\222.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e756ddb4a04924827f05e67e3dea605fc72bfa6d --- /dev/null +++ "b/30\344\275\231\350\276\211/10/\346\235\250\350\276\211\344\270\211\350\247\222.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class 杨辉三角 + { + public void aa() + { + Console.WriteLine("请输入数字"); + int a = int.Parse(Console.ReadLine()); + int[,] arr = new int[a,a]; + for (int i = 0; i < a; i++) + { + for (int j = 0; j <= i ; j++) + { + if (j == 0 || j == i) + { + arr[i, j] = 1; + Console.Write(arr[i,j] +"\t"); + } + else + { + arr[i, j] = arr[i - 1, j - 1] + arr[i, j - 1]; + Console.Write(arr[i, j] + "\t"); + } + } + Console.WriteLine(); + } + } + } +} diff --git "a/30\344\275\231\350\276\211/11/.keep" "b/30\344\275\231\350\276\211/11/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/30\344\275\231\350\276\211/11/Calculate.cs" "b/30\344\275\231\350\276\211/11/Calculate.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6a1466d4e578a65170555c2ba2addbf3edcc76a9 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Calculate.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Calculate + { + //创建Calculate基类,其中包含两个整型的protected成员, + //用以接收用户输入的两个整数。定义一个DisplayResult()虚方法,计算并输出结果。 + protected int a; + protected int b; + public Calculate(int a,int b) + { + this.a= a; + this.b = b; + } + public virtual void DisplayResult() + { + Console.WriteLine("计算并输出"); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Circle.cs" "b/30\344\275\231\350\276\211/11/Circle.cs" new file mode 100644 index 0000000000000000000000000000000000000000..62095faba5cd928b537d3006a1277796b40e3919 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Circle.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Circle:Shape + { + //圆 + public int radius;//半径 + public override void GetArea() + { + Console.WriteLine("圆形的面积为" + (3.14*radius*radius)); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Class1.cs" "b/30\344\275\231\350\276\211/11/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..826755b255a1cd22a5c36d0ba6de627ed7b596d7 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Class1.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class1:Calculate + { + public Class1(int a, int b):base(a,b) + { + this.a = a; + this.b = b; + } + public override void DisplayResult() + { + Console.WriteLine("加法运算" + (a + b)); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Class2.cs" "b/30\344\275\231\350\276\211/11/Class2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e00017d0b184cec7c10aa378e6a406d8d06208ff --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Class2.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class2:Calculate + { + public Class2(int a, int b):base(a,b) + { + this.a = a; + this.b = b; + } + public override void DisplayResult() + { + Console.WriteLine("减法结果" + (a-b)); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Class3.cs" "b/30\344\275\231\350\276\211/11/Class3.cs" new file mode 100644 index 0000000000000000000000000000000000000000..da6c87892fb34674b60106632000692180f341f2 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Class3.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class3:Calculate + { + public Class3(int a, int b):base(a,b) + { + this.a = a; + this.b = b; + } + public override void DisplayResult() + { + Console.WriteLine("乘法结果" + (a * b)); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Class4.cs" "b/30\344\275\231\350\276\211/11/Class4.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a8ca696bfd76cfdb34f0d477385168f49a28ee25 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Class4.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Class4:Calculate + { + public Class4(int a, int b):base(a,b) + { + this.a = a; + this.b = b; + } + public override void DisplayResult() + { + Console.WriteLine("除法结果" + (a / (double)b)); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Program.cs" "b/30\344\275\231\350\276\211/11/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7814aab2b9dd255b9dc9abe631cf98fbee9fa4e5 --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Program.cs" @@ -0,0 +1,49 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("---------第一题-----------"); + Console.WriteLine("请输入两个数"); + int a = Convert.ToInt32(Console.ReadLine()); + int b = Convert.ToInt32(Console.ReadLine()); + + Console.WriteLine("请输入想要运算的方法 加 + 减 - 乘 * 除 /"); + string op = Convert.ToString(Console.ReadLine()); + switch (op) + { + case "+": + Class1 class1 = new Class1(a,b); + class1.DisplayResult(); + break; + case "-": + Class2 class2 = new Class2(a,b); + class2.DisplayResult(); + break; + case "*": + Class3 class3 = new Class3(a,b); + class3.DisplayResult(); + break; + case "/": + Class4 class4 = new Class4(a,b); + class4.DisplayResult(); + break; + } + Console.WriteLine("---------第2题-----------"); + Square square = new Square();//正方形 + { + square.color = "正方形"; + square.sideLen = 5; + } + square.GetArea(); + Circle circle = new Circle();//圆形 + { + circle.color = "圆形"; + circle.radius = 5; + } + circle.GetArea(); + } + + } +} \ No newline at end of file diff --git "a/30\344\275\231\350\276\211/11/Shape.cs" "b/30\344\275\231\350\276\211/11/Shape.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f6c88b2aca3baa3cc888a82bced97801ac4db5c --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Shape.cs" @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Shape + { + //创建一个Shape(形状)类,此类包含一个名为color的数据成员, + //用于存储颜色,这个类还包含一个名为GetArea()的虚方法(这个方法是用来获取形状面积的)。 + public string color; + public virtual void GetArea() + { + Console.WriteLine("获取图形面积"); + } + } +} diff --git "a/30\344\275\231\350\276\211/11/Square.cs" "b/30\344\275\231\350\276\211/11/Square.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cb6f5119bb543ecea79b53f92bddc007dc4c26ae --- /dev/null +++ "b/30\344\275\231\350\276\211/11/Square.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Square:Shape + { + //正方形 + public int sideLen;//边长 + public override void GetArea() + { + Console.WriteLine("正方形面积为" + (sideLen*sideLen)); + } + } +}