




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
using System; using System.Collections.Generic; using System.Text; namespace Proj7_15 public class Employee/普通职工类 private double bsalary= 1000;/基本工资 private double psalary;/实际工资 private int n;/工作年数 public int pn get return n; set n = value; public double compsalary()/计算普通员工工资 Console.Write(“工作年数:“); pn = int.Parse(Console.ReadLine(); psalary = bsalary+30*pn; return psalary; public class UEmployee : Employee/本科生职工类 new public double compsalary() return 1.5 * psalary(); class Program static void Main(string args) Employee emp1 = new Employee(); Console.WriteLine(“该普通职工工资:0“, psalary(); UEmployee emp2 = new UEmployee(); Console.WriteLine(“该本科生职工工资:0“, psalary(); using System; using System.Collections.Generic; using System.Text; namespace Proj7_16 public class Employee/普通职工类 private double bsalary = 1000;/基本工资 private double psalary;/实际工资 private int n;/工作年数 public int pn get return n; set n = value; public virtual double compsalary()/计算普通员工工资 Console.Write(“工作年数:“); pn = int.Parse(Console.ReadLine(); psalary = bsalary + 30 * pn; return psalary; public class UEmployee : Employee/本科生职工类 public override double compsalary() return 1.5 * psalary(); public class GEmployee : Employee/研究生职工类 public override double compsalary() return 2 * psalary(); class Program static void Main(string args) Employee emp1 = new Employee(); Console.WriteLine(“该普通职工工资:0“, psalary(); UEmployee emp2 = new UEmployee(); Console.WriteLine(“该本科生职工工资:0“, psalary(); GEmployee emp3 = new GEmployee(); Console.WriteLine(“该研究生职工工资:0“, psalary(); using System; using System.Collections.Generic; using System.Text; namespace Proj7_17 public class Person/人类 private int no;/编号 private string name;/姓名 public void input() Console.Write(“编号:“); no = int.Parse(Console.ReadLine(); Console.Write(“姓名:“); name = Console.ReadLine(); public void disp() Console.WriteLine(“编号:0“,no); Console.WriteLine(“姓名:0“,name); public class Student : Person/学生类 private string sclass;/班号 private int degree;/成绩 public void input() base.input(); Console.Write(“班号:“); sclass = Console.ReadLine(); Console.Write(“成绩:“); degree = int.Parse(Console.ReadLine(); new public void disp() base.disp(); Console.WriteLine(“班号:0“,sclass); Console.WriteLine(“成绩:0“,degree); public class Teacher : Person/教师类 private string prof;/职称 private string depart;/部门 public void input() base.input(); Console.Write(“职称:“); prof = Console.ReadLine(); Console.Write(“部门:“); depart = Console.ReadLine(); new public void disp() base.disp(); Console.WriteLine(“职称:0“, prof); Console.WriteLine(“部门:0“, depart); class Program static void Main(string args) Student s1 = new Student(); Teacher t1 = new Teacher(); Console.WriteLine(“输入一个学生数据:“); s1.input(); Console.WriteLine(“输入一个教师数据:“); t1.input(); Console.WriteLine(“显示一个学生数据:“); s1.disp(); Console.WriteLine(“显示一个教师数据:“); t1.disp(); using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace Proj7_18 public class Student:IComparable private string name; private int eng, math, sum; public int psum get return sum; public void inscore() Console.Write(“姓名:“); name = Console.ReadLine(); Console.Write(“英语:“); eng = int.Parse(Console.ReadLine(); Console.Write(“数学:“); math = int.Parse(Console.ReadLine(); sum = eng + math; public void display() Console.WriteLine(“t0t1t2t3“, name, eng, math, sum); public int CompareTo(object obj)/实现接口方法 Student s = (Student)obj;/转换为Student实例 if (psum s.psum) return 1; else if (psum = s.psum) return 0; else return -1; class Program static void Main(string args) int n, i; ArrayList myarr = new ArrayList(); Student p;/定义对象引用 Console.Write(“n:“); n = int.Parse(Console.ReadLine(); for (i = 0; i n; i+) Console.WriteLine(“输入第0个学生数据:“, i + 1); p = new Student();/创建对象引用实例 p.inscore(); myarr.Add(p); Console.WriteLine(“排序前:“); Console.WriteLine(“t姓名t英语t数学t总分“); i = 1; foreach(Student s in myarr) Console.Write(“序号0:“, i+); s.display(); myarr.Sort();/按总分降序排序 Console.WriteLine(“排序后:“); Console.WriteLine(“t姓名t英语t数学t总分“); i = 1; foreach (Student s in myarr) Console.Write(“第0名:“, i+); s.display(); using System; using System.Collections.Generic; using System.Text; namespace Proj7_19 public class BClass/基类 private string name;/名称 private int no;/编号 public BClass(string na, int n)/构造函数 name = na; no = n; public void show() Console.Write(“0(1)“, name, no); public class Book : BClass/图书类 string author;/作者 public Book(string na, int n, string auth) : base(na, n) author = auth; public void showBook() base.show(); Console.Write(“作者:0“, author); public class Reader : BClass/读者类 Book rent;/所借图书 int top; public Reader(string na, int n) : base(na, n)/构造函数 rent = new Book5; top = 0; public void rentBook(ref Book b) renttop = b; top+; public void showReader() Console.Write(“读者:“); base.show(); Console.WriteLine(“所借图书:“); for (int i = 0; i top; i+) Console.Write(“0:“, i + 1);/5个空格 renti.show(); Console.WriteLine(); class Program static void Main(string args) Book b1 = new Book(“C语言“, 100, “潭浩强“); Book b2 = new Book(“数据结构“, 110, “严蔚敏“); Bo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO 80369-6:2025 EN Small bore connectors for liquids and gases in healthcare applications - Part 6: Connectors for neural applications
- 【正版授权】 IEC 60654-1:1993 EN-D Industrial-process measurement and control equipment - Operating conditions - Part 1: Climatic conditions
- 【正版授权】 IEC TS 63224:2025 EN Management of network assets in power systems - Management aspects
- 城市交通智能化升级项目协议
- 旅游服务行业从业及表现证明(5篇)
- 机械工程原理及设备维护案例分析
- 农业领域产品种类表
- 艺德家政考试试题及答案
- 六一助残活动方案
- 六一商场品牌活动方案
- 人力资源管理2025年考试试卷及答案
- 安徽省合肥市庐江县2023-2024学年七年级下学期6月期末数学试题
- 2025年氯硝西泮项目市场调查研究报告
- T/DZJN 136-2023家用燃气快速热水器全程节能分级评价规范
- 郑州中原绿色产业生态发展公司招聘笔试真题2024
- 深圳市非承重墙体与饰面工程施工及验收标准SJG 14-2018
- 2025至2030中国芳纶纤维行业需求预测及发展前景趋势研究报告
- 十一学校小升初入学测试数学真题及详细解答
- 婚内赌博欠债协议书范本
- 造价咨询项目管理制度
- XX公司事故隐患内部报告奖励制度1
评论
0/150
提交评论