1208060201徐春霞 (2)_第1页
1208060201徐春霞 (2)_第2页
1208060201徐春霞 (2)_第3页
1208060201徐春霞 (2)_第4页
1208060201徐春霞 (2)_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

9.2 Design and implement a set of classes that define the employees of a hospital: doctor , nurse , administrator , surgeon , receptionist , janitor , and so on . Include methods in each class that are named according to the services provided by that person and that print an appropriate message . Create a main driver class to instantiate and exercise several of the classes.设计和实现的一组类,定义一个医院的员工:医生,护士,管理员,外科医生,接待员,看门人,等等。包括每个类中的方法,根据提供的服务命名人,打印一个适当的消息。创建一个主要驱动力类实例化和锻炼的几类package one;import java.util.Scanner;public class one public static void main(String args) Scanner input = new Scanner(System.in);while (true) System.out.println(请输入在医院的职位:);System.out.println(1代表 doctor,2 代表 nurse,3 代表 surgeon,+ 4 代表 janitor,5代表 administer,6代表receptionist);int a = input.nextInt();switch (a) case 1:doctor a1 = new doctor();a1.doctor();break;case 2:nurse a2 = new nurse();a2.nurse();break;case 3:surgeon a3 = new surgeon();a3.surgeon();break;case 4:janitor a4 = new janitor();a4.janitor();break;case 5:administer a5 = new administer();a5.administer();break;case 6:receptionist a6 = new receptionist();a6.receptionist();break; System.out.println(Do you want to continue?(Y or N);String key = input.next();if (key.equalsIgnoreCase(n) System.out.println(Thanks for your usingGoogBye);break;static class doctor public static void doctor() System.out.println( 我是一名医生!n如果你生病了我可以治愈你!);static class nurse public static void nurse() System.out.println(我是一名护士!n如果你生病了我可以照顾你!);static class administer public static void administer() System.out.println(我是一名管理员!n我可以管理医院中的所有员工!);static class janitor public static void janitor() System.out.println(我是一名门卫!n我可以确保医院的安全!);static class surgeon public static void surgeon() System.out.println(我是一名外科医生!n如果你受伤我可以给你做手术!);static class receptionist public static void receptionist() System.out.println(我是一名接待员!n让你感到宾至如归的感觉!);9.3 Design and implement a set of classes that define various types of reading material: books , novels , magazines , technical journals , textbooks , and so on . Include data values that describe various attributes of the material , such as the number of pages and the names of the primary characters. Include methods that are named appropriately for each class and that print an appropriate message . Create a main driver class to instantiate and exercise several of the classes.设计和实现一组类定义各种类型的阅读材料:书籍、小说、杂志、技术期刊,教科书等等。包括数据值来描述材料的各种属性,如页面的数量和主要人物的名字。包括适当的方法命名为每个类和打印一个适当的消息。创建一个主要驱动力类实例化和锻炼的几类package one;import java.util.Scanner;public class one public static void main(String args) Scanner input = new Scanner(System.in);while (true) System.out.println(请输入书的种类:);System.out.println(1代表book,2 代表 novel,3 代表 magazine,+ 4 代表 technologyjournal,5代表 text);int a = input.nextInt();switch (a) case 1:book a1 = new book();a1.book();break;case 2:novel a2 = new novel();a2.novel();break;case 3:magazine a3 = new magazine();a3.magazine();break;case 4: technologyjournal a4 = new technologyjournal();a4. technologyjournal();break;case 5:text a5 = new text();a5.text();break;System.out.println(Do you want to continue?(Y or N);String key = input.next();if (key.equalsIgnoreCase(n) System.out.println(Thanks for your usingGoogBye);break;static class book public static void book() System.out.println( 这部书的页数是80页,主要人物的名字是Sam);static class novel public static void novel() System.out.println(这部小说的页数是300页,主要人物的名字是林黛玉和贾宝玉);static class magazine public static void magazine() System.out.println(这部杂志的页数是40页,主要人物的名字是Bob);static class technologyjournalpublic static void technologyjournal() System.out.println(这部技术期刊的页数是110页,主要人物的名字是act);static class text public static void text() System.out.println(这部课本的页数是230页,主要人物的名字是Alice);9.4 Design and implement a set of classes that keeps track of various sports statistics. Have each low-level class represent a specific sport . Tailor the services of the classes to the sport in question , and move common attributes to the higher-level classes as appropriate . Create a main driver class to instantiate and exercise several of the classes.设计和实现一套类,各种运动的跟踪统计。有每个低级类代表一个特定的运动。定制服务类的运动,并将公共属性移动到更高级的课程。创建一个主要驱动力类实例化和锻炼的几类。package one;import java.util.Scanner;public class one public static void main(String args) Scanner input = new Scanner(System.in);while (true) System.out.println(请输入一种运动:);System.out.println(1代表basketball,2 代表banminton ,3 代表pingpang ,);int a = input.nextInt();switch (a) case 1:basketball a1 = new basketball();a1.basketball();break;case 2:banminton a2=new banminton (); a2.banminton(); break;case 3:pingpang a3 = new pingpang();a3. pingpang();break;System.out.println(Do you want to continue?(Y or N);String key = input.next();if (key.equalsIgnoreCase(n) System.out.println(Thanks for your usingGoogBye);break;static class basketball public static void basketball() System.out.println( 打篮球的男生比较多);static class banmintonpublic static void banminton() System.out.println(羽毛球是一种很常见的运动方式);static class pingpangpublic static void pingpang() System.out.println(中国的乒乓球团队比较厉害);9.5 Design and implement a set of classes that keeps track of demographic information about a set of people , such as age , nationality , occupation , income , and so on . Design each class to focus on a particular aspect of data collection . Create a main driver class to instantiate and exercise several of the classes.设计和实现一套类跟踪人口信息的一组人,比如年龄、国籍、职业、收入等。每个类设计数据收集的专注于一个特定的方面。创建一个主要驱动力类实例化和锻炼的几类。package one;import java.util.Scanner;public class one public static void main(String args) Scanner input = new Scanner(System.in);while (true) System.out.println(请输入人口信息调查的一个方面:);System.out.println(1代表age,2 代表 nationality,3 代表 profession,+ 4 代表 income);int a = input.nextInt();switch (a) case 1:age a1 = new age();a1.age();break;case 2:nationality a2=new nationality(); a2.nationality(); break;case 3: profession a3 = new profession();a3. profession();break;case 4:income a4 = new income();a4. income();break;System.out.println(Do you want to continue?(Y or N);String key = input.next();if (key.equalsIgnoreCase(n) System.out.println(Thanks for your usingGoogBye);break;static class age public static void age() System.out.println( BOb的平均年龄80);static class nationality public static void nationality() System.out.println(Bob的国籍是美国);static class profession public static void profession() System.out.println(Bob的职业是作家);static class incomepublic static void income() System.out.println(Bob的收入是每年100万);5.import java.util.Scanner;interface compareTopublic abstract float compare(student a); class student implements compareToint number;String name;float C_socre;float java_socre;float Chinese_socre;Scanner r=new Scanner(System.in); public float compare(student a)return average()-a.average();student(int nu,String na,float c,float j,float C)number=nu;name=na;C_socre=c; java_socre=j; Chinese_socre=C;student()this(0,0,0,0);void get() System.out.println(请依次输入下列学生信息:n名字 学号 c成绩 java成绩 语文成绩); name=r.next(); number=r.nextInt(); C_socre=r.nextFloat(); java_socre=r.nextFl

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论