讲解:Java、Java、Java、Java

CSE1/CSE4IOO Semester 1, 2018Assignment – Part 2Assessment: This Part 2 of the assignment is worth 15% of the final mark for this subject.Due Date: Monday 28 May 2018 at 10.00 amDelays caused by computer downtime cannot be accepted as a valid reason for a late submissionwithout penalty. Students must plan their work to allow for both scheduled and unscheduleddowntime. Penalties are applied to late assignments, accepted up to 5 days after the due date only.Individual Assignment: This is an individual assignment. You are not permitted to work as agroup when writing this assignment.Copying, Plagiarism: Plagiarism is the submission of somebody else’s work in a manner thatgives the impression that the work is your own. The Department of Computer Science and Com-puter Engineering treats academic misconduct seriously. When it is detected, penalties are strictlyimposed.Objectives: The general aims of this assignment are:• To analyze a problem in an object-oriented manner, and then design and implement anobject-oriented solution that conforms to given specifications• To practise using inheritance in Java• To practise file input and output in Java• To make implementations more robust through mechanisms such as exception handling.Submission Details and Marking Scheme: Instructions on how to submit electronic copies ofyour source code files from your latcs8 account and a marking scheme overview are given at theend.If you have not been able to complete a program that compiles and executes containing all func-tionality, then you should submit a program that compiles and executes with as much functionalityas you have completed. You may comment out code that does not compile. However, the com-mented out code will not be marked.Deployment Platform. While you are free to develop the code for this assignment on anyoperating system, your solution must run on the latcs8 system. We should be able to compileyour classes with the simple command javac *.java, and execute your programs with a simplecommand, e.g. java PatientRecordSystemMenu.1BackgroundAs described in the handout for Part 1, the overall aim of the assignment is to develop a prototypefor a patient record system.In Part 1, you have implemented the classes to represent patients, medical observation types, andobservations. You have also implemented a PatientRecordSystem class which allows us to addpatients, observation types and observations.Building on the work that you have done for part 1, in this Part 2, you are required to do the tasksdescribed below.Essentially, you will• expand on the functionality of the classes that you have developed in Part 1, and• implement a menu programBesides the information given in the tasks below, please refer to Part 1 of the Assignment for otherinformation you need.Task 1Implement two methods for the PatientRecordSystem class to save data and to ld data.The first method, with the headerpublic void saveData() throws Exceptionwill save the data to five text files:• PRS-MeasurementObservationTypes.txtThis file saves the measurement observation types. A sample is shown below:T100; Blood Pressure; psiT400; Height; cmEach measurement observation type is on a separate line. It contain the observation type code,name and unit, separated by semi-colons.• PRS-CategoryObservationTypes.txtThis file saves the category observation types. A sample is shown below:T200; Blood Type; Group A, Group B1, Group B2T300; Stress Level; Low, Medium, HighEach category observation type is on a separate line. It contain the observation type code, nameand the categories. The three “fields” code, the name and the categories are separated by semi-colons. In the categories field, the categories are separated by commas.• PRS-Patients.txtThis file saves the patients’s data without their observations. A sample is shown below:P100; John SmithP200; Anna BellEach patient is on a separate line. It contain the patient’s id and name, separated by a semi-colon.2• PRS-MeasurementObservations.txtThis file saves the patients’s measurement observations. A sample is shown below:P100; T100; 120.0P200; T400; 180Each measurement observation is on a separate line. It contain the patient’s id, the observationcode and the observation value (a double). The fields are separated by semi-colons.• PRS-CategoryObservations.txtThis file saves the patients’s category observations. A sample is shown below:P100; T200; Group AP200; T300, LowEach measurement observation is on a separate line. It contain the patient’s id, the observationcode and the observation value (a double). The fields are separated by semi-colons.The second method, with the headerpublic void loadData() throws Exceptionwill read the data from five text files and save them in a PatientRecordSystem instance bycalling methods to add measurement observation types, category observation types, etc.The data should be loaded into a PatientRecordSystem instance which is empty of data.Of course, you may need to enhance other classes to support the implementation of the saveDataand loadData methods.Also, you should write a small program to test your methods. A sample test program is given inthe Appendix 1.As for Part 1, your implementation must be such that the sample test program can be runwithout any change.The sample test program is more or less the bare minimum. You should add more test cases to it.3Task 2Write the menu program, called PatientRecordSystemMenu, to provide options in the followingmenu:=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by the patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X):The menu program must use the PatientRecordSystem class developed for Task 1.For each option, the program should ask for the required inputs, each with a separate prompt.For option 6, 7 and D, it is acceptable just to use the toString methods of the classes involved(which should have been implemented in Part 1 of the assignment).See Appendix 2 for a short sample run.The menu program for this task is only required to satisfy the data correctness conditions. It is notrequired to be robust, i.e. it can crash when certain exceptions occur.Task 3- Making the Menu Program RobustImplement a class called RobustPatientRecordSystemMenu, which extends the previous menuand includes enough exception handling features to make it robust. It is required to be robust onlyin the following sense: when an exception occurs in the execution of an option, the program willdisplay some information about the exception on the screen and return to the min menu.Task 4. (For CSE4IOO students only)This task is not related to the Patient Record System. For the purpose of this task, a string isregarded as having the correct syntax for an email if it satisfies the following conditions:• Condition 1: It is a sequence of lowercase letters, the period character (’.’), and the @character• Condition 2: The @ character must appear once and must appear between two letters• Condition 3; The period character can appear zero or more times, and it must appear betweentwo letters4Write an EmailChecker class, which has methods with headers:• public static boolean checkCharacters(String email)which returns true if Condition 1 is satisfied, and false otherwise• public static boolean checkAt(String email)which returns true if Condition 2 is satisfied, and false otherwise• public static boolean checkDot(String email)which returns true if Condition 3 is satisfied, and false otherwise• public static boolean checkEmail(Stri代做留学生Java语言、Java程序代做、调试Java编程作业、Java语言代做留学生ng email)which returns true if the string has the valid format for an email, and false otherwise.Submit the EmailChecker and a EmailCheckerTestter class.(The total mark for Part 2 will be 100 for CSE1IOO students and 110 for CSE4IOO students. Thepercentage of contribution to the final will be the same.)Electronic Submission of the Source Code• Submit all the Java files that you have developed in the tasks above.• The code has to run under Unix on the latcs8 machine.• You submit your files from your latcs8 account. Make sure you are in the same directory asthe files you are submitting.• Submit each file separately using the submit command. For example, for the file called (say)ObservationType.java, use command:submit IOO ObservationType.java• After submitting the files, you can run the following command that lists the files submittedfrom your account:verify• You can submit the same filename as many times as you like before the assignment deadline;the previously submitted copy will be replaced by the latest one.Marking Scheme OverviewImplementation (Execution of code) 90% (Do all parts of the programs execute correctly? Noteyour programs must compile and run to carry out this implementation marking.)Program Design and Coding Style. 10% (Does the program conform. to specifications? Does theprogram solve the problem in a well-designed manner? Does the program follow good program-ming practices? Does the indentation and code layout follow a good, consistent standard? Are theidentifiers meaningful? Are comments being used effectively?)5Return of AssignmentsAssignments are to be returned within 3 weeks of the submission date. Students will be notified byemail and via the CSE1/CSE4IOO website news when marking sheets are available for collection.Appendix 1 – A Program to Test Methods to Save and Load Dataimport java.io.*;import java.util.*;public class PatientRecordSystemTester{public static void main(String [] args) throws Exception{testSaveData();testLoadData(); // this method calls testSaveData ()}public static void testSaveData() throws Exception{// Create PatientRecordSystem// Add observation types , patients and observationsPatientRecordSystem prs = new PatientRecordSystem();prs.addMeasurementObservationType(&"T100&", &"Blood Pressure&", &"psi&");String [] categories = {&"Group A&", &"Group B1&", &"Group B2&"};prs.addCategoryObservationType(&"T200&", &"blood type&", categories);String [] temp = {&"low&", &"Medium&", &"high&"};categories = temp;prs.addCategoryObservationType(&"T300&", &"stress level&", categories);prs.addMeasurementObservationType(&"T400&", &"height&", &"cm&");prs.addPatient(&"P100&", &"Smith&");prs.addPatient(&"P200&", &"Adams&");prs.addMeasurementObservation(&"P100&", &"T100&", 120);prs.addCategoryObservation(&"P100&", &"T200&", &"Group A&");// save data to fileprs.saveData();}public static void testLoadData() throws Exception{testSaveData();PatientRecordSystem prs = new PatientRecordSystem();prs.loadData();System.out.println(prs);}}6Appendix 2 – A Sample Run of the Menu Program=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): 2Enter observation type code: t1Enter observation type name: stress levelEnter the number of categories: 3Enter category 1: lowEnter category 2: mediumEnter category 3: high=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): d--------------------------PATIENT RECORD SYSTEM DATA--------------------------OBSERVATION TYPES:-- CategoryObservationType[code: t1, name: stress level, categories: |low|medium|high|]PATIENTS:Please press the ENTER key to continue:=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspection7X. ExitPlease enter an option (1-9 or D or X): 3Enter patient ID: p1Enter patient Name: john smith=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): d--------------------------PATIENT RECORD SYSTEM DATA--------------------------OBSERVATION TYPES:-- CategoryObservationType[code: t1, name: stress level, categories: |low|medium|high|]PATIENTS:-- Patient id: p1, name: john smithObservations:Please press the ENTER key to continue:=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): 5Enter patient ID: p1Enter observation type code: t1Enter observation type value: medium=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id88. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): d--------------------------PATIENT RECORD SYSTEM DATA--------------------------OBSERVATION TYPES:-- CategoryObservationType[code: t1, name: stress level, categories: |low|medium|high|]PATIENTS:-- Patient id: p1, name: john smithObservations:- CategoryObservation[observationType: CategoryObservationType[code: t1, name: stress level, categories: |low|medium|high|], value: medium]Please press the ENTER key to continue:=====================Patient Record System=====================1. Add a measurement observation type2. Add a category observation type3. Add a patient4. Add a measurement observation5. Add a category observation6. Display details of an observation type7. Display a patient record by patient id8. Save data9. Load dataD. Display all data for inspectionX. ExitPlease enter an option (1-9 or D or X): x& 转自:http://ass.3daixie.com/2018052758777495.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,509评论 6 504
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,806评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,875评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,441评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,488评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,365评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,190评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,062评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,500评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,706评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,834评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,559评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,167评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,779评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,912评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,958评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,779评论 2 354

推荐阅读更多精彩内容

  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,856评论 0 0
  • 近来,再次向西蒙的作品发起挑战。前一阵略略看懂了他的《人类活动中的理性》,心感庆幸。今晚由于身体原因,不想做过于耗...
    雨精灵喜欢双休日阅读 587评论 0 0
  • 最近一直觉得自己情绪低落,今天真的是到了一个极点:那是一种做什么都提不起热情来的无奈和无力,我真的不知道究竟什么才...
    张露deer阅读 211评论 0 0
  • 回到家,听到奶奶在训斥孩子,快点吃!和儿子打招呼的时候,看到奶奶一勺一勺喂着。地上都是孩子用一包包纸巾搭盖的半成品...
    意念婆娑阅读 238评论 0 1
  • 银杏树作为世界上最古老的树种之一,有“活化石”“植物界的熊猫”之美称。银杏生长较慢,寿命极长。我的老家有许许多多的...
    无涯过客2018阅读 336评论 0 3