diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\344\272\224\344\270\200\346\270\270\346\210\217/\344\272\224\344\270\200\346\270\270\346\210\217.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\344\272\224\344\270\200\346\270\270\346\210\217/\344\272\224\344\270\200\346\270\270\346\210\217.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c1420ef1070389e3f8aa6e27b95fcd3470c524e1 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\344\272\224\344\270\200\346\270\270\346\210\217/\344\272\224\344\270\200\346\270\270\346\210\217.cs" @@ -0,0 +1,173 @@ +namespace 游戏作业 +{ + internal class Program + { +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); + + } + 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; } + + + + } + +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); + } +internal class Teacher:person + { + //职称(Title)、工资号(Wageno) + public string Title; + public string Wageno; + public void way3() + { + Console.WriteLine("职称:{0}",Title); + Console.WriteLine("工资号;{0}",Wageno); + } + 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); + + } + 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 = 146468; + student1.Name = "渣男彪彪"; + student1.Sex = '男'; + student1.Cardid = "14348686"; + student1.Tel = 542144348686; + student1.Major = "新媒体"; + student1.Grade = "幼儿园扛把子"; + student1.way1(); + student1.way2(); + Console.WriteLine("----------教师------------"); + Teacher Teacher1=new Teacher(); + Teacher1.Id = 368464; + Teacher1.Name = "深情男高"; + Teacher1.Sex = '男'; + Teacher1.Cardid = "147258369"; + Teacher1.Tel = 2845258348686; + Teacher1.Title = "渣男宝贝"; + Teacher1.Wageno = "886646814646849436562"; + 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 = "为什么你从来不答应我"; + 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 = "闪现q"; + 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/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3b0554231f098a8b12321fdfd0c32ccf1a5ab755 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237/\345\233\276\344\271\246\347\256\241\347\220\206\347\263\273\347\273\237.cs" @@ -0,0 +1,262 @@ +namespace 类和属性作业 +{ + internal class Program + { + public class Book + { + //3.定义一个图书类,存放图书的编号、书名、价格、出版社、作者信息; + // 对价格进行赋值限制,小于0价格,赋值为0 + // 在图书类中定义一个方法输出图书信息; + // 在主方法实例化对象,赋值并输出 + private int bookid; + private string bookname; + private double price; + private string publisher; + private string autor; + + public int Bookid { get => bookid; set => bookid = value; } + public string Bookname { get => bookname; set => bookname = value; } + public double Price + { + get + { + return price; + } + set + { + if (value < 0) + { + return; + } + else + { + price = value; + } + } + } + public string Publisher { get => publisher; set => publisher = value; } + public string Autor { get => autor; set => autor = value; } + public void PrintInfo() + { + Console.WriteLine($"图书编号:{this.bookid}"); + Console.WriteLine($"书名:{bookname}"); + Console.WriteLine($"价格:{price}"); + Console.WriteLine($"出版社:{publisher}"); + Console.WriteLine($"作者信息:{autor}"); + Console.WriteLine($""); + } + public class Student + { + //2.定义一个学生类,存放学生的学号、姓名、性别、年龄、专业信息; + // 对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + // 在学生类中定义一个方法输出学生信息。 + // 在主方法实例化对象,赋值并输出 + private int id; + private string name; + public char sex; + private int age; + private string majorinfo; + public int Id + { + get + { + return id; + } + set + { + id = value; + } + } + + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + public int Age + { + get + { + return age; + } + set + { + if(value < 0 || value > 128) + { + age = 0; + } + else + { + age = value; + } + } + } + + public string Majorinfo + { + get + { + return majorinfo; + } + set + { + majorinfo= value; + } + } + + public void PrintInfo() + { + Console.WriteLine($"学号{this.id}"); + Console.WriteLine($"姓名{name}"); + Console.WriteLine($"性别{sex}"); + Console.WriteLine($"年龄{age}"); + Console.WriteLine($"专业信息{majorinfo}"); + Console.WriteLine(); + } + public class User + { + //1.定义一个用户类,存放用户的账号、用户名和密码属性; + // 在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息;然后在主方法调用输出; + private int account; + private string name; + private string password; + public int Account + { + get + { + return account; + } + set + { + account = value; + } + } + + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + public string Password + { + get + { + return password; + } + set + { + password = value; + } + } + public void PrintInfo() + { + Console.WriteLine("账号" + this.account); + Console.WriteLine("用户名" + name); + Console.WriteLine("密码" + password); + Console.WriteLine(); + } + + + + + static void Main(string[] args) + { + //## 练习 + + //1.定义一个用户类,存放用户的账号、用户名和密码属性; + // 在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息;然后在主方法调用输出; + + Console.WriteLine("user1的数据是:"); + User user1 = new User(); + user1.Account = 123456789; + user1.Name = "666"; + user1.Password = "password"; + user1.PrintInfo(); + + Console.WriteLine("user2的数据是:"); + User user2 = new User(); + user2.Account =2582582588 ; + user2.Name = "999"; + user2.Password = "niube"; + user2.PrintInfo(); + + //2.定义一个学生类,存放学生的学号、姓名、性别、年龄、专业信息; + // 对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + // 在学生类中定义一个方法输出学生信息。 + // 在主方法实例化对象,赋值并输出 + + Console.WriteLine("Student1的信息是:"); + Student student1 = new Student(); + student1.Id = 1; + student1.Name = "渣男"; + student1.sex = '男'; + student1.Age = 18; + student1.Majorinfo = "zhanangaisi"; + student1.PrintInfo(); + + Console.WriteLine("Student2的信息是:"); + Student student2 = new Student(); + student2.Id = 2; + student2.Name = "xiaochen"; + student2.sex = '女'; + student2.Age = 18; + student2.Majorinfo = "aixiaochen"; + student2.PrintInfo(); + + Console.WriteLine("Student3的信息是:"); + Student student3 = new Student(); + student3.Id = 3; + student3.Name = "henaixiaochen"; + student3.sex = '女'; + student3.Age = 18; + student3.Majorinfo = "baby"; + student3.PrintInfo(); + + //3.定义一个图书类,存放图书的编号、书名、价格、出版社、作者信息; + // 对价格进行赋值限制,小于0价格,赋值为0 + // 在图书类中定义一个方法输出图书信息; + // 在主方法实例化对象,赋值并输出 + + Console.WriteLine("图书1的信息是:"); + Book book1 = new Book(); + book1.Bookid = 1; + book1.Bookname = "sejie"; + book1.Price = 666.6; + book1.Publisher = "haishisejie"; + book1.Autor = "liangchaowei"; + book1.PrintInfo(); + + Console.WriteLine("图书2的信息是:"); + Book book2 = new Book(); + book2.Bookid = 1; + book2.Bookname = "woshizhengren"; + book2.Price = 298; + book2.Publisher = "me"; + book2.Autor = "haose"; + book2.PrintInfo(); + + Console.WriteLine("图书3的信息是:"); + Book book3 = new Book(); + book3.Bookid = 1; + book3.Bookname = "3333"; + book3.Price = 333333; + book3.Publisher = "zhitousan"; + book3.Autor = "womenqunaliya"; + book3.PrintInfo(); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201 (2).md" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201 (2).md" new file mode 100644 index 0000000000000000000000000000000000000000..ff4fbbf8a6833f44c203c0cfefce20aafc9c8e35 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201 (2).md" @@ -0,0 +1,71 @@ +using System.Security.Cryptography.X509Certificates; + +namespace 多态作业2 +{ + internal class Program + { + static void Main(string[] args) + { + //二、创建一个Shape(形状)类,此类包含一个名为color的数据成员,用于存储颜色, + //这个类还包含一个名为GetArea()的虚方法(这个方法是用来获取形状面积的)。 + //基于这个Shape,创建两个子类:Circle(圆形类)和Square(正方形类), + //Circle类中包含radius(半径)的数据成员,Square类中包含sideLen(边长)的数据成员, + //这两个子类都去重写父类的GetArea()方法,各自去实现计算自己的面积。 + + //在主类中添加一个方法,参数类型就是Shape,方法体中,用形参去调用GetArea()方法。 + //main方法中去测试这个方法。 + Shape circle = new Circle("黑色",2); + Print(circle); + Shape square = new Square("白色",6); + Print(square); + } + public static void Print(Shape shape) + { + shape.GetArea(); + } + } + class Shape + { + public string color; + + public Shape(string color) + { + this.color = color; + } + + public virtual void GetArea() + { + + } + } + class Circle : Shape + { + + public double redius; + + public Circle(string color,double redius) : base(color) + { + this.redius = redius; + } + + public override void GetArea() + { + Console.WriteLine($"半径为{redius}、颜色为{color}的圆面积为{redius * redius * 3.14}"); + } + } + class Square : Shape + { + + public double sideLen; + + public Square(string color,double sideLen) : base(color) + { + this.sideLen = sideLen; + } + + public override void GetArea() + { + Console.WriteLine($"边长为{sideLen}、颜色为{color}的正方形的面积为{sideLen * sideLen}"); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201.md" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201.md" new file mode 100644 index 0000000000000000000000000000000000000000..9ba2933f6034d7d0cbf0dd80339608afe2519445 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\345\244\232\346\200\201/\345\244\232\346\200\201.md" @@ -0,0 +1,125 @@ +using System.Security.Cryptography.X509Certificates; + +namespace ConsoleApp1 +{ + internal class Program + { + + + + + + //1、创建Calculate基类,其中包含两个整型的protected成员,用以接收用户输入的两个整数。定义一个DisplayResult()虚方法,计算并输出结果。 + //2、定义四个类继承自Calculate类,分别重写DisplayResult()方法,实现两个整数的加、减、乘、除运算,并输出结果。 + //3、根据用户输入的操作符,实例化相应的类,完成运算并输出结果。 + //4、在主类中添加一个方法,形参为父类对象,根据传递实参的类型,调用方法,实现计算和显示结果。 + + + //二、创建一个Shape(形状)类,此类包含一个名为color的数据成员,用于存储颜色,这个类还包含一个名为GetArea()的虚方法(这个方法是用来获取形状面积的)。 + //基于这个Shape,创建两个子类:Circle(圆形类)和Square(正方形类),Circle类中包含radius(半径)的数据成员,Square类中包含sideLen(边长)的数据成员,这两个子类都去重写父类的GetArea()方法,各自去实现计算自己的面积。 + + //在主类中添加一个方法,参数类型就是Shape,方法体中,用形参去调用GetArea()方法。 + //main方法中去测试这个方法。 + + static void Main(string[] args) + { + + // 一、编写一个控制台应用程序,接受用户输入的两个整数和一个操作符,以实现对两个整数的加、减、乘、除运算,并显示出计算结果。 + Console.WriteLine("请输入第一个数字"); + + int A= Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("请输入第二个数字"); + + int B = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("请输入一个运算符"); + string C = Console.ReadLine(); + + + int result; + switch (C) + { + case"+": + result =A+B; + break; + case "-": + result =A-B; + break; + case "*": + result = A + B; + break; + case "/": + result = A + B; + break; + } + Calculate(Calculate); + + + } + //在主类中添加一个方法,形参为父类对象,根据传递实参的类型,调用方法,实现计算和显示结果。 + public static void Calculate(Calculate calculate) + { + calculate.DisplayResult(): + } + } + class Calculate + { + //其中包含两个整型的protected成员,用以接收用户输入的两个整数 + protected int A; + protected int B; + public Calculate(int A, int B) + { + this.A = A; + this.B = B; + } + //定义一个DisplayResult()虚方法,计算并输出结果 + public virtual void DisplayResult() + { + //运算由子类实现 + } + + } + class Add : Calculate + { + public Add(int A, int B) : base(A, B) + { + + } + public override void DisplayResult() + { + Console.WriteLine($"{A}+{B}={A + B}"); + } + } + class Sub : Calculate + { + public Sub(int A, int B) : base(A, B) + { + + } + public override void DisplayResult() + { + Console.WriteLine($"{A}-{B}={A - B}"); + } + } + class Mul : Calculate + { + public Mul(int A, int B) : base(A, B) + { + + } + public override void DisplayResult() + { + Console.WriteLine($"{A}*{B}={A * B}"); + } + } + class Div : Calculate + { + public Div(int A, int B) : base(A, B) + { + + } + public override void DisplayResult() + { + Console.WriteLine($"{A}/{B}={A / B}"); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" new file mode 100644 index 0000000000000000000000000000000000000000..63d0ede1a27149c3b00259edf1fed1fe12d6889f --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" @@ -0,0 +1,155 @@ +using System.ComponentModel.Design.Serialization; + +namespace one +{ + internal class Program + { + static void Main(string[] args) + { + /** + //1.求圆的面积 + //要求用户输入半径的值,打印出以此值为半径的圆的面积 + Console.WriteLine("请输入圆的半径"); + double r = double.Parse(Console.ReadLine()); + //圆周率π定义成常量取3.14。 + const double π = 3.14; + //求圆的面积的公式:πr²。 + Console.WriteLine(π * r * r); + //r由用户输入并存入一个变量中此变量用double比较合适,因为用户可能会输入小数。 + + //2.编写一个程序,请用户输入一个四位整数 + Console.WriteLine("请输入一个四位整数"); + int a = int.Parse(Console.ReadLine()); + //将用户输入的四位数的千位、百位、十位和个位分别显示出来,如5632,则显示“用户输入的千位为5,百位为6,十位为3,个位为2” + int 千 = a / 1000; + int 百 = a % 1000 / 100; + int 十 = a % 100 / 10; + int 个 = a % 10; + Console.WriteLine("你输入的是" + a + "\n输入的千位为" + 千 + "\n百位为" + 百 + "\n十位为" + 十 + "\n个位为" + 个); + //3.用户输入三个数,找出最大的数,打印输出。 + Console.WriteLine("请输入三个数"); + int b = int.Parse(Console.ReadLine()); + int 百2 = b / 100; + int 十2 = b % 100 / 10; + int 个2 = b % 10; + int max = 百2; + if (十2 > max) + { + max = 十2; + } + if (个2 > max) + { + max = 个2; + }; + Console.WriteLine("你输入的是" + b + "最大值是" + max); + + //a) 接受用户输入一个数n,求这个数的阶乘;5! = 5 * 4 * 3 * 2 * 1; + Console.WriteLine("请输入一个整数"); + int c = int.Parse(Console.ReadLine()); + Console.WriteLine("你输入的数是"+c); + for(int c1=c;c1>0;c1--) + { + c *= c1; + } + Console.WriteLine("这个数的阶乘是"+c); + //.接受用户输入的一个数n,求n到1所有数的阶乘和;n! + (n - 1!) + (n - 2)! +……+1! + Console.WriteLine("请输入一个整数"); + int d = int.Parse(Console.ReadLine()); + for (int d1 = d;d1>0;d1--) + { + for (int d2 = d1;d2>0;d2--) + d *= d1; + } + + Console.WriteLine(); + //5.根据用户输入的菱形边长,打印菱形;如边长为3,行数为5; + for (int f = 1; f <= 3; f++) + { + for (int f1 = 1; f1 <= 3 - f; f1++) + { + Console.Write(" "); + } + for (int f2 = 1; f2 <= 2 * f - 1; f2++) + { + Console.Write("*"); + } + Console.WriteLine(); + } + for (int f = 2; f >= 1; f--) + { + for (int f1 = 1; f1 <= 3 - f; f1++) + { + Console.Write(" "); + } + for (int f2 = 1; f2 <= 2 * f - 1; f2++) + { + Console.Write("*"); + } + Console.WriteLine(); + } + + + //6.用循环打印九九乘法表(用二维数组保存字符串后再打印) + for (int d = 1; d < 10; d++) + { + for (int e = 1; e <= d; e++) + { + Console.Write(d + "x" + e + "=" + d * e + "\t"); + } + Console.WriteLine(); + } + + //7.输入一行字符串,分别统计出其中英文字母、数字、空格的个数。 + int zm = 0; + int sz = 0; + int kg = 0; + int fh = 0; + Console.WriteLine("输入一行字符串"); + string sr = Console.ReadLine(); + char[] sr1 = sr.ToString().ToCharArray(); + foreach(char s in sr1) + { + if (s >= 'a' && s <= 'z' || s >= 'A' && s <= 'Z') + zm++; + else if (s>='1'&&s<='9') + sz++; + else if (s==' ') + kg++; + else + fh++; + } + Console.WriteLine($"字母{zm},数字{sz}空格{kg}符号{fh}"); + //8.在 Main 方法中创建一个 double 类型的数组,并在该数组中存入 5 名学生的考试成绩,计算总成绩和平均成绩。(要求使用foreach语句实现该功能 + double[] scores = { 50,40,60,10,70 }; + + double sum = 0; + double avg = 0; + foreach (double score in scores) + { + sum = sum + score; + } + avg = sum / 5; + Console.WriteLine("总成绩为:" + sum); + Console.WriteLine("平均成绩为:" + avg); + + //9.定义一个方法,实现一维数组的排序功能,从大到小排序。(不要用Array类的方法) + + int[] qq = { 50, 40, 60, 10, 70 }; + for (int i = 0; i < qq.Length; i++) + { + for (int j = 0; j < qq.Length - i - 1; j++) + { + if (qq[j] < qq[j + 1]) + { + int temp = qq[j]; + qq[j] = qq[j + 1]; + qq[j + 1] = temp; + } + } + } + Console.WriteLine("从大到小排序:"); + foreach (int b in qq) + { + Console.Write(b + "\t"); + } + Console.WriteLine(); \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/3.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/3.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d71891a3b3b90bd856301ddc8f24aad98d849afc --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/3.cs" @@ -0,0 +1,149 @@ +using System.Runtime.CompilerServices; + +namespace wyjHomework +{ + // 1. 定义一个用户类,存放用户的账号、用户名和密码属性; + //在用户类中定义一个方法输出当前用户对象的账号、用户名和密码的信息;然后在主方法调用输出; + public class User + { + public User(int id, string name, string password) + { + this.Id = id; + this.Name = name; + this.Password = password; + } + public int Id { get; set; } + public string Name { get; set; } + public string Password { get; set; } + public void PrintMsg() + { + Console.WriteLine("账号:" + this.Id); + Console.WriteLine("用户名:" + this.Name); + Console.WriteLine("密码:" + this.Password); + } + } + class program + { + static void Main(string[] args) + { + User user = new User(19, "肖肖", "xiao123123"); + user.PrintMsg(); + } + } + //2.定义一个学生类,存放学生的学号、姓名、性别、年龄、专业信息; + //对年龄字段进行赋值的安全性设置,如果是非法值(小于0或者大于128岁),该年龄值为0; + //在学生类中定义一个方法输出学生信息。 + //在主方法实例化对象,赋值并输出 + public class Student + { + private int id; + private string name; + private int age; + private string major; + public Student(int id, string name, int age, string major) + { + this.id = id; + this.name = name; + this.age = age; + this.major = major; + } + public int Id + { + get { return id; } + set { id = value; } + } + public string Name + { + get { return name; } + set { name = value; } + } + public int Age + { + get { return age; } + set + { + if (value > 0 && value < 128) + { + age = value; + } + else + { + age = 0; + } + } + } + public string Major + { + get { return major; } + set + { + major = value; + } + } + public void Printmsg() + { + Console.WriteLine("学号:" + this.id); + Console.WriteLine("姓名:" + this.name); + Console.WriteLine("年龄:" + this.age); + Console.WriteLine("专业:" + this.major); + } + static void Main(string[] args) + { + Student x = new Student(19, "肖肖", 3, "软件技术"); + x.Printmsg(); + } + //3.定义一个图书类,存放图书的编号、书名、价格、出版社、作者信息; + //对价格进行赋值限制,小于0价格,赋值为0 + //在图书类中定义一个方法输出图书信息; + //在主方法实例化对象,赋值并输出 + public class Book + { + public int id; + public string name; + public double price; + public void SetBook(int id, string name, double price) + { + this.Id = id; + this.Name = name; + this.Price = price; + } + public int Id + { + get { return id; } + set { id = value; } + } + public string Name + { + get { return name; } + set { name = value; } + } + public double Price + { + get { return price; } + set + { + if (value >= 0) + { + price = value; + } + else + { + price = 0; + } + } + } + public void PrintMsg() + { + Console.WriteLine("图书编号:" + Id); + Console.WriteLine("图书名称:" + Name); + Console.WriteLine("图书价格:" + Price); + } + static void Main(string[] args) + { + Book book = new Book(); + book.SetBook(9, "查理九世", 30); + book.PrintMsg(); + } + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\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/40\345\217\267\347\216\213\347\224\237\345\274\230/\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..cb2fc6f9d616a5887415b0626ad5eaaf767da81c --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\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,78 @@ +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + //1. + Console.WriteLine("善学如春起之苗"); + Console.WriteLine("不见其增,日有所长"); + Console.WriteLine("假学如磨刀之石"); + Console.WriteLine("不见其损,年有所亏"); + Console.WriteLine("加油吧!少年"); + Console.WriteLine("J\nA\nV\nA\n!\n"); + //2. + Console.WriteLine("true"); + Console.WriteLine("false"); + //3. + 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. + 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. + int a = 10; + int b = 20; + int temp = a; + a = b; + b = temp; + Console.WriteLine("a的值是"+a); + Console.WriteLine("b的值是"+b); + //6. + 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); + //7. + 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/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ConsoleApp3/FileContentIndex/b8ee39e0-ea18-41fd-b53e-720a96eb87dd.vsidx" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ConsoleApp3/FileContentIndex/b8ee39e0-ea18-41fd-b53e-720a96eb87dd.vsidx" new file mode 100644 index 0000000000000000000000000000000000000000..4e875559581212218ac9f812f76d3f24c89c477f Binary files /dev/null and "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ConsoleApp3/FileContentIndex/b8ee39e0-ea18-41fd-b53e-720a96eb87dd.vsidx" differ diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ConsoleApp3/FileContentIndex/read.lock" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ConsoleApp3/FileContentIndex/read.lock" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.metadata.v5.2" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.metadata.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..4ecec546818d6b2fe4847e94e7d7c7b6a133c746 Binary files /dev/null and "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.metadata.v5.2" differ diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.projects.v5.2" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.projects.v5.2" new file mode 100644 index 0000000000000000000000000000000000000000..b626d643d318e91ec4147ccb3dd7ff259047905b Binary files /dev/null and "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/.vs/ProjectEvaluation/consoleapp3.projects.v5.2" differ diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Area.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Area.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3c0f1b72343d7d8e2ba27fce10f4904dd272f889 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Area.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +namespace ConsoleApp3 +{ + internal class Area + { + public double Square(double r) + { + return Math.PI * r * r; + } + + public double Square(double length, double width) + { + return length * width; + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Book.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Book.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ffcafbe587a5069e94b488ee14f17f575ce2223d --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Book.cs" @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class Book + { + 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 { title = value; } + } + public string Description + { + get { return description; } + set { description = value; } + } + public string Author + { + get { return author; } + set { author = value; } + } + + public void PrintBook() + { + Console.WriteLine("编号:" + bookid); + Console.WriteLine("书名:" + bookname); + Console.WriteLine("价格:" + title); + Console.WriteLine("出版社:" + description); + Console.WriteLine("作者信息:" + author); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Class1.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5fb49469027b30f47d7a211fa508f5e23935c08e --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Class1.cs" @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class Class1 + { + } +} diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.csproj" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..40c60dd4c884340c455eab8a0020f7c681a4e76c --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.csproj" @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.sln" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.sln" new file mode 100644 index 0000000000000000000000000000000000000000..b696956ff7a53b32cafc751d04bcd6add80d30b6 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/ConsoleApp3.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp3", "ConsoleApp3.csproj", "{017CA913-6E67-4443-9E7D-8771D17EE48D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {017CA913-6E67-4443-9E7D-8771D17EE48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {017CA913-6E67-4443-9E7D-8771D17EE48D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {017CA913-6E67-4443-9E7D-8771D17EE48D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {017CA913-6E67-4443-9E7D-8771D17EE48D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97E538F-779E-4147-8D31-968FD06CEE92} + EndGlobalSection +EndGlobal diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Enemy.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Enemy.cs" new file mode 100644 index 0000000000000000000000000000000000000000..31df39bea415afe5cf644acab8334d3b06bd5d99 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Enemy.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class Enemy + { + public int hp; + public int attack; + public int magic; + + public Enemy(int hp, int attack, int magic) + { + this.hp = hp >= 0 ? hp : 0; + this.attack = attack >= 0 ? attack : 0; + this.magic = magic >= 0 ? magic : 0; + } + + public void Attack() + { + Console.WriteLine("敌人正在攻击!!!"); + } + public void Escape() + { + Console.WriteLine("敌人正在逃跑!!!"); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Hero.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e910aa07609faa30ad49b8686c87e05ca6cc3058 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Hero.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class Hero + { + public string name { get; set; } + public int attack { get; set; } + public int defense { get; set; } + public int hp { get; set; } + public int magic { get; set; } + public void PrintHero() + { + Console.WriteLine("英雄" + name + "正在攻击!!!"); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Program.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..09b1b72e49dc3682ed63604a960c2f549c155859 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Program.cs" @@ -0,0 +1,74 @@ +namespace ConsoleApp3 +{ + +// 1. 定义一个计算图形面积的类,类中定义2个计算面积的方法(重载,方法名相同),分别计算圆面积和长方形面积两个方法。 +//提示:计算圆的面积传半径,计算长方形面积传长和宽。 + +//2.创建一个名为计算工具类 SumUtils,在类中定义4个方法: +// 计算两个整数相加、 +// 两个小数相加、 +// 两个字符串相加、 +// 以及从 1 到指定整数的和的方法。 +//在 Main 方法中分别调用定义好的方法。 + +//提示:根据题目要求,分别定义 3 个带两个参数的方法,以及一个带一个整型参数的方法, +// 四个方法名相同。 + + + internal class Program + { + static void Main(string[] args) + { + Area area = new Area(); + Console.WriteLine("圆的面积是" + area.Square(5)); + Console.WriteLine("长方形面积是" + area.Square(4, 5)); + + SumUtils sumUtils = new SumUtils(); + Console.WriteLine("两整数之和是" + sumUtils.Add(1, 5)); + Console.WriteLine("两小数之和是" + sumUtils.Add(2.6, 5.7)); + Console.WriteLine("两字符串相加是" + sumUtils.Add("Hello" + " ", "C#")); + Console.WriteLine("1-11的和是" + sumUtils.Add(11)); + + User user = new User(); + user.Account = "s20230419"; + user.UserName = "admin"; + user.Password = "1234567"; + user.PrintUser(); + Console.WriteLine("您的身份是:" + user.Login()); + + Student student = new Student(); + student.StuNo = 20230419; + student.StuName = "张三"; + student.Sex = '男'; + student.Age = 158; + student.Major = "软件技术"; + student.PrintUSer(); + + Book book = new Book(); + book.BookId = "s20230419"; + book.BookName = "Test"; + book.Title = 222; + book.Description = "Test出版社"; + book.Author = "张三"; + book.PrintBook(); + + Enemy enemy1 = new Enemy(100,120,150); + Enemy enemy2 = new Enemy(-20, -60, -100); + Console.WriteLine("敌人1的属性值是:血量={0},攻击力={1},魔法值={2}",enemy1.hp,enemy1.attack,enemy1.magic,enemy1.Attack,enemy1.Escape); + Console.WriteLine("敌人1的属性值是:血量={0},攻击力={1},魔法值={2}",enemy2.hp,enemy2.attack,enemy2.magic,enemy2.Attack,enemy2.Escape); + + enemy1.Attack(); + enemy2.Escape(); + + + Hero hero = new Hero(); + hero.name = "张三"; + hero.attack = 100; + hero.defense = 100; + hero.hp = 100; + hero.magic = 100; + hero.PrintHero(); + } + } + +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Student.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7d4681d287ab0c33c0fa9bded8b661519d9e7ad4 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/Student.cs" @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class Student + { + private int stuno; + private string stuname; + private char sex; + private int age; + private string major; + + public int StuNo + { + get { return stuno; } + set { stuno = value; } + } + public string StuName + { + get { return stuname; } + set { stuname = value; } + } + public char Sex + { + get { return sex; } + set { sex = value; } + } + public int Age + { + get { return age; } + set + { + if (value < 0 || value > 128) + { + value = 0; + } + else + { + age = value; + } + } + } + public string Major + { + get { return major; } + set { major = value; } + } + + public void PrintUSer() + { + Console.WriteLine("学号:" + stuno); + Console.WriteLine("姓名:" + stuname); + Console.WriteLine("性别:" + sex); + Console.WriteLine("年龄:" + age); + Console.WriteLine("专业信息:" + major); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/SumUtile.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/SumUtile.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7b998744e503d44fdae5c8cafed211aea8bd0cdf --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/SumUtile.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class SumUtils + { + public int Add(int a, int b) + { + return a + b;//return(回来) + } + + public double Add(double a, double b) + { + return a + b; + } + + public string Add(string a, string b) + { + return a + b; + } + + public int Add(int n) + { + int sum = 0; + for (int i = 0; i <= n; i++) + { + sum += i; + } + return sum; + } + + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/User.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..83f2b17f24c91d1f74bbe689981c9121e709a5a9 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/User.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + internal class User + { + public string Account; + public string UserName; + public string Password; + + public void PrintUser() + { + Console.WriteLine("账号:{0},用户名:{1},密码:{2}", Account, UserName, Password); + } + + public string Login() + { + if (UserName == "admin" && Password == "123456") + { + return "管理员"; + } + else + { + return "普通用户"; + } + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.dgspec.json" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.dgspec.json" new file mode 100644 index 0000000000000000000000000000000000000000..1c5b534cc15be8aefbddd438c9ea8efd4ccac47f --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.dgspec.json" @@ -0,0 +1,63 @@ +{ + "format": 1, + "restore": { + "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj": {} + }, + "projects": { + "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj", + "projectName": "ConsoleApp3", + "projectPath": "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj", + "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", + "outputPath": "E:\\C#\\40王生弘作业\\ConsoleApp3\\obj\\", + "projectStyle": "PackageReference", + "configFilePaths": [ + "C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.102\\RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.props" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.props" new file mode 100644 index 0000000000000000000000000000000000000000..ac1dfe0953a9f1fe32694308542114620593b129 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.props" @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\Administrator\.nuget\packages\ + PackageReference + 6.4.0 + + + + + \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.targets" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.targets" new file mode 100644 index 0000000000000000000000000000000000000000..35a7576c5a5ead1cdee2137a1838d11d571c5325 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/ConsoleApp3.csproj.nuget.g.targets" @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.assets.json" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.assets.json" new file mode 100644 index 0000000000000000000000000000000000000000..0c36a4478d05d4897e5beb523aa41f50db3a29fb --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.assets.json" @@ -0,0 +1,68 @@ +{ + "version": 3, + "targets": { + "net6.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net6.0": [] + }, + "packageFolders": { + "C:\\Users\\Administrator\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj", + "projectName": "ConsoleApp3", + "projectPath": "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj", + "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", + "outputPath": "E:\\C#\\40王生弘作业\\ConsoleApp3\\obj\\", + "projectStyle": "PackageReference", + "configFilePaths": [ + "C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.102\\RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.nuget.cache" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.nuget.cache" new file mode 100644 index 0000000000000000000000000000000000000000..6e11e24a98d706561c7dd6c7c24dbc28eea7642a --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/ConsoleApp3/obj/project.nuget.cache" @@ -0,0 +1,8 @@ +{ + "version": 2, + "dgSpecHash": "hpkHQpFeBJSF0zMyk8AqnGezLpSbds5yyJYR3AvBQJlCyoK9An0SjdsqVHqoNj2FevBONMaT46FhVYwXgfBuLQ==", + "success": true, + "projectFilePath": "E:\\C#\\40王生弘作业\\ConsoleApp3\\ConsoleApp3.csproj", + "expectedPackageFiles": [], + "logs": [] +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2771.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2771.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f7948e5075a5a66d27f205683318044df29d091b --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2771.cs" @@ -0,0 +1,98 @@ +namespace ConsoleApp1 +{ + internal class Program + { + + // 1. 定义一个员工类,作为基类,包含姓名,性别,年龄等属性;包含一个方法代表工作的行为 + + //2. 定义一个医生类,继承员工类,重写工作的方法,描述医生的具体工作 + + //3. 定义一个程序员类,继承员工类,重写工作方法,描述程序员具体工作 + + //4. 定义一个清洁工类,继承员工类,重写工作方法,描述清洁工的具体工作 + + //5. 在主方法中为每个类实例化一个对象,用每个对象调用工作方法; + + static void Main(string[] args)//实例化 + { + Cleanr cleanr= new Cleanr("赖志生",'女',3); + cleanr.behavior(); + Doctor driver= new Doctor("钱泰铭",'女',18); + driver.behavior(); + Programmer programmer = new Programmer("木翔",'男',58); + programmer.behavior(); + } + + } +} +internal class yg//定义属性 + { + public string Name { get; set; } + public char Sex { get; set; } + public double Year { get; set; } + + public yg(string name,char sex,double year)//定义一个有参 + { + this.Name=Name; + this.Sex = Sex; + this.Year = Year; + } + public yg() //定义一个无参 + { + } + public virtual void behavior()//行为 + { + Console.WriteLine(""); + } + } +internal class Cleanr:yg + { + public Cleanr(string Name,char Sex,double Year) //有参 + { + this.Name = Name; + this.Sex = Sex; + this.Year = Year; + } + public Cleanr()//无参 + { + } + public override void behavior()//行为 + { + base.behavior(); + Console.WriteLine($"{Name}正在打扫卫生"); + } + } +internal class Doctor:yg + { + public Doctor(string Name,char Sex,double Year) + { + this.Name = Name; + this.Sex = Sex; + this.Year = Year; + } + public Doctor() //无参 + { + } + public override void behavior() + { + base.behavior(); + Console.WriteLine($"{Year}的{Name}{Sex}医生正在给病人看病"); + } + }internal class Programmer:yg + { + public Programmer(string Name, char Sex, double Year) + { + this.Name = Name; + this.Sex = Sex; + this.Year = Year; + } + public Programmer() + { + + } + public override void behavior() + { + base.behavior(); + Console.WriteLine($"{Year}的{Name}正在秃头"); + } + } \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2772.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2772.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1279aad92ec5a661371b154200726a613a47fd6b --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\347\273\247\346\211\277/\347\273\247\346\211\2772.cs" @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 虚方法 +{ + //1. 动物类:具有动物的共同属性:腿,重量等;共同行为:吃,叫,睡 + internal class Animal + { + public string Name { get; set; }//姓名 + public int Leg { get; set; }//腿 + public int Weight { get; set; }//重量 + public Animal(string name, int leg, int weight) + { + Name = name; + Leg = leg; + Weight = weight; + } + + public Animal() + { + } + + + public virtual void Eat() + { + Console.WriteLine($"{Name}有{Leg}条腿,{Weight}kg,吃吃吃"); + } + public virtual void Cry() + { + Console.WriteLine($"{Name}有{Leg}条腿,{Weight}kg,叫叫叫"); + } + public virtual void Sleep() + { + Console.WriteLine($"{Name}有{Leg}条腿,{Weight}kg,睡睡睡"); + } + + internal class Bird : Animal + { + public string Name { get; set; } + public Bird() + { + } + + public Bird(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public void Fly() + { + Console.WriteLine($"{Name}是鸟类动物具有飞行能力"); + } + } + + internal class Cat:Animal + { + + + public int Beard { get; set; }//胡须 + + + public Cat() + { + } + + public Cat(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public void NightVision() + { + Console.WriteLine("猫科类动物具有夜视能力"); + } + } + + internal class Tiger : Cat + { + public Tiger() + { + } + + public Tiger(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public override void Eat() + { + base.Eat(); + Console.WriteLine("老虎正在吃肉"); + } + public override void Cry() + { + //base.Cry(); + Console.WriteLine("老虎正在交配"); + } + } + + internal class Kitty : Cat + { + + + public Kitty() + { + } + + public Kitty(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public override void Eat() + { + base.Eat(); + Console.WriteLine("猫正在吃大饼"); + } + public override void Cry() + { + //base.Cry(); + Console.WriteLine("猫在哭 孩子没了"); + } + } + internal class Eagle : Bird//老鹰 + { + public Eagle() + { + } + + public Eagle(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public override void Eat() + { + base.Eat(); + Console.WriteLine("老鹰再吃屎壳郎的孩子"); + } + public override void Cry() + { + //base.Cry(); + Console.WriteLine("老鹰正在哭 屎壳郎把他的孩子推下了巢穴"); + } + } + + internal class Swallow : Bird + { + public Swallow() + { + } + public Swallow(string name, int leg, int weight) : base(name, leg, weight) + { + } + + public override void Eat() + { + base.Eat(); + Console.WriteLine("麻雀在吃蚯蚓"); + } + public override void Cry() + { + //base.Cry(); + Console.WriteLine("麻雀在喳喳喳"); + } + } + + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\207\215\350\275\275/\351\207\215\350\275\275.cs" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\207\215\350\275\275/\351\207\215\350\275\275.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6f0f9c700a02134b409e5c685d23b664ba479721 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\207\215\350\275\275/\351\207\215\350\275\275.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/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243 (2).txt" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243 (2).txt" new file mode 100644 index 0000000000000000000000000000000000000000..8c884ac558523ec77ff4d167c9fa6c34c73c0d57 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243 (2).txt" @@ -0,0 +1,59 @@ +namespace 静态字段 +{ + internal class Program + { + static void Main(string[] args) + { + ban ban1 = new ban("666"); + ban ban2 = new ban("999"); + ban.teachname = "dapiaoliang"; + ban1.print(); + ban2.print(); + ban.teachname = "xiaoqi"; + ban1.print(); + ban2.print(); + student student1 = new student(2, "momotui", '变态'); + student1.print1(); + } + } + class ban + { + string stuname; + + public ban(string stuname) + { + this.stuname = stuname; + } + + public static string teachname; + + public string Stuname { get => stuname; set => stuname = value; } + public void print() + { + Console.WriteLine("大家好,我是" + stuname + ",我的老师叫" + teachname); + } + } + class student + { + int id; + string name; + char sex; + + public student(int id, string name, char sex) + { + this.id = id; + this.name = name; + this.sex = sex; + } + + public int Id { get => id; set => id = value; } + public string Name { get => name; set => name = value; } + public char Sex { get => sex; set => sex = value; } + public void print1() + { + Console.WriteLine("学号为" + id); + Console.WriteLine("姓名为" + name); + Console.WriteLine("性别为" + sex); + } + } +} \ No newline at end of file diff --git "a/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" new file mode 100644 index 0000000000000000000000000000000000000000..f31a2771c906af7a17a62ecd0db372cd269639a7 --- /dev/null +++ "b/40\345\217\267\347\216\213\347\224\237\345\274\230/\351\235\231\346\200\201/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" @@ -0,0 +1,55 @@ +namespace 静态2 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("请输入字符串"); + StringUtil.ch = Console.ReadLine(); + Console.WriteLine(StringUtil.su()); + Console.WriteLine(ArrayUtil.shuzu()); + } + } + class StringUtil + { + public static string ch; + public static bool su() + { + if (ch == "null") + { + return true; + } + else if (ch == " ") + { + return true; + } + else if (string.IsNullOrWhiteSpace(ch)) + { + return true; + } + else + { + return false; + } + } + } + class ArrayUtil + { + public static string[] arr = new string[0]; + public static bool arrs() + { + if (arr == null) + { + return true; + } + else if (arr.Length == 0) + { + return true; + } + else + { + return false; + } + } + } +} \ No newline at end of file