COMP1721留学生程序 写作、 辅导java编程

” COMP1721留学生程序 写作、 辅导java编程COMP1721 Object-Oriented ProgrammingCoursework 1: Creating Using Classes1 IntroductionYour task is to write a Java program that analyzes COVID-19 cases amongst staff, students and otherindividuals at the University of Leeds, as reported at httpss://coronavirus.leeds.ac.uk/statistics-and-support-available/You must do this by creating the classes described by the UML diagram in Figure 1. The class CaseRecordrepresents the cases recorded on a given date as a result of positive tests for COVID-19. The classCovidDataset represents a chronological sequence of these records.There are three different levels of solution: basic, full and advanced. The UML diagram summarizes therequirements for the full solution. The advanced solution is aimed at people who complete the lower levelsquickly and want some additional challenge.Figure 1: Main classes used in Coursework 1.2 PreparationIt is important that you Follow the instructions below precisely.1. Download cwk1-files.zip from Minerva or Teams. Put this file in the coursework directory ofyour repository.2. Unzip the Zip archive. You can do this from the command line in Linux, macOS and WSL 2 withunzip cwk1-files.zip.3. Make sure that you have the following files and subdirectories immediately below cwk1:app/ config/ gradle/ README.htmlbuild.gradle core/ gradlew README.mdchart/ datafiles/ gradlew.bat settings.gradleIMPORTANT: Make sure that this is exactly what you see! For example, you should NOT havea subdirectory of cwk1 that is itself named cwk1. Thus the path to the README file, relative to therepository directory, should be coursework/cwk1/README.md. Fix any problems with the directorystructure before proceeding any further.4. Remove cwk1-files.zip. Use Git to add and commit the new files, then push your commit upto gitlab.com. The following commands, executed in a terminal window while in the courseworkdirectory of your repository, will achieve all of this:git add cwk1git commit -m Initial files for Coursework 1git push13 Skeleton ClassesThe first step is to create skeletons of the two classes shown in Figure 1. These are needed because we haveprovided a set of tests that We will use when marking your work, which you can also use yourself to assessyour progress. These tests will be of no use until they compile, and they will only compile once youveprovided stubs (dummy versions) of the methods in the two classes.1. Edit CaseRecord.java, in the directory core/src/main/java/comp1721/cwk1. Within the classdefinition for CaseRecord add a constructor with four parameters: A LocalDate object representing the date on which cases were recorded An int value representing the number of staff cases An int value representing the number of student cases An int value representing the number of other casesDont put anything in the body of the constructor yet. Note that youll need to import LocalDatefrom the java.time package.2. Implement the CaseRecord methods shown in Figure 1 as stubs. Use the exact same method namesand return types as shown in the UML diagram. If a method is supposed to return a numeric value,make it return the value 0. If a method is supposed to return an object of some kind, make it returnnull.3. Edit CovidDataset.java, in the directory core/src/main/java/comp1721/cwk1. Within the classdefinition for CovidDataset add stubs for the methods shown in Figure 1. Use the exact samemethod names, parameter types and return types as shown in the UML diagram. If a method issupposed to return a numeric value, make it return the value 0. If a method is supposed to return anobject of some kind, make it return null. Constructors and methods that dont return anything shouldjust have empty method bodies (i.e., nothing inside the braces).4. Attempt to run the tests with./gradlew :core:test(On Windows, omit the ./ from the start of this command.)If youve implemented the classes and their stub methods properly, the tests should compile and runbut almost all of them should display FAILED in the terminal window.Consult the README file in cwk1 for further details of how to run tests selectively and how to viewtest results in a web browser.5. Commit the code Changes to your Git repository.4 Basic SolutionThe features of the basic solution are worth 13 marks. These marks are awarded for passing a set of tests.You can run these tests like this:./gradlew :core:test –tests BasicThe –tests Basic in this command ensures that only the tests for the basic solution are run. You canomit it to run all the tests.4.1 CaseRecordAdd the required fields to CaseRecord, then replace the method stubs with correct implementations. Afterimplementing each method, rerun the tests, as shown above.The getter methods should return the corresponding field values.The totalCases method should return the total number of COVID cases recorded in a CaseRecord.The toString method should return a string containing all the field values from the CaseRecord, formattedso that it looks like this example:2020-10-07: 2 staff, 59 students, 0 other2An attempt to create a CaseRecord with a negative value for staff cases, student cases or other cases shouldresult in a DatasetException being thrown, containing an appropriate error message. You have beenprovided with this exception class and do not need to write it yourself.There are 7 tests relating specifically to the CaseRecord class in the Basic solution. Make sure all of theseare passing before proceeding any further.4.2 CovidDatasetThis class represents an ordered sequence of CaseRecord objects. It will need a field capable of storingthese objects, so the first step is to add this field, plus a default constructor that initializes it.Next, turn your attention to the addRecord, getRecord and size method stubs. Replace each of these withthe required implementation and rerun the tests to check whether youve done this correctly.The addRecord method should append the given CaseRecord object to the end of the current sequence ofrecords stored in a CovidDataset.The getRecord method should return the CaseRecord object stored at the given position, specified as azero-based integer index. It Should throw a DatasetException if the supplied index is not valid.The size method should return the number of CaseRecord objects stored in a CovidDataset.Finally, implement the dailyCasesOn method. This method should find and return the CaseRecord objectcorresponding to the given date. If no CaseRecord can be found for the given date, the method should throwa DatasetException, containing an appropriate error message.There are 6 tests relating specifically to the CovidDatset class in the basic solution. Make sure all of theseare passing before proceeding any further.5 Full SolutionThe features of the full solution are worth a further 11 marks. 6 marks are awarded for passing the automatedtests and 5 marks are awarded for implementing a program that uses the two classes. You can run only thetests for the Full solution like this:./gradlew :core:test –tests FullOmit –tests Full from this command if you want to run all the tests.5.1 CovidDataset1. Consult the README in the datafiles directory, then examine the file 2020-daily.csv in a texteditor (not in a spreadsheet application). Each line of this CSV file (after the initial column headings)represents one record of the dataset. Your code will need to convert each of these lines into a suitableCaseRecord object, which should then be stored in the CovidDataset for later use.2. Replace the stub for readDailyCases with an implementation that reads from a CSV file whose nameis given by the method parameter. Note the following points regarding readDailyCases: It should not catch any exceptions that occur during reading of a CSV file. It will need an exception specificationeither for FileNotFoundException or IOException,depending on the approach youve used to read the data. Reading data from a file should clear out any data previously held in the CovidDataset. It is OK for a dataset to be emptyi.e., it is OK for the CSV file to contain column headings butno case records.3. Replace the stub for writeActiveCases with an implementation that computes the number of activecases on each day, for each category of individual (staff, student, other). The method should writethe active case data out to a CSV file whose name is given by the methods filename parameter. Theformat for the output file should identical to the format of the daily cases filei.e., same columns andcolumn headings.The number of active cases on any given day is defined as the sum of the number of casesrecorded over the past 10 days, including the given day.3Note the following points regarding writeActiveCases: You can assume that a CovidDataset holds consecutive days of data, with no missing days. You should skip the first nine days of data in a CovidDataset, since the tenth record in thedataset is the first for Which a valid count of active cases can be produced. Your method should throw a DatasetException if there are not at least ten CaseRecord objectsstored in the CovidDataset. Your method should not catch any exceptions that occur during writing of the CSV file. Your method will need an exception specification for IOException.Make sure that all 6 tests pass before proceeding to the final part of the Full solution.5.2 ActiveCases ProgramEdit the file ActiveCases.java, in app/src/main/java/comp1721/cwk1. In this file, write a programthat reads daily case data from a CSV file and then writes active cases to a different CSV file.The names for these two files should be provided on the command line, with the daily cases file specified asthe first command line argument, and the active cases file specified as the second command line argument.If the user of the program fails to provide two command line arguments, your program should print a helpfulusage message and then terminate.After reading and writing data, your program should display the number of records that were in theCovidDataset. It should display no other output (aside from error messagessee below).Your program should catch any exceptions that occur during the reading, processing or writing of data. Theerror message associated with the caught exception should be displayed, then the program should terminatewith a non-zero status code (to signify that an error of some kind has occurred).You can run the program from the command line with./gradlew :app:runThis will use files datafiles/2020-daily.csv and datafiles/2020-active.csv as the command linearguments. You can check the contents of the latter file to see if your program is behaving correctly.6 Advanced TaskThis task is more challenging and will require you to do some additional research. Also, it is worthonly 5 marks. You should attempt it only if you manage to complete the Basic and Full solutions fairlyquickly and easily.1. Investigate JavaFXe.g, by reading Chapter 6 of Ecks Introduction to Programming Using Javaand trying out some of the examples.2. Visit https://bit.ly/jfxcharts to learn about drawing charts in JavaFX.3. Edit the file CovidChart.java, in chart/src/main/java/comp1721/cwk1. In this file, create aprogram that reads COVID case data from a CSV file and then draws a line chart showing how thetotal number of active cases changes over time.Your program should make use of the classes developed for the Basic and Full solutions. The x axisof the chart should be day of the year, which can be obtained from the LocalDate object associatedwith a CaseRecord.You should be able to Compile and run the program with./gradlew :chart:runThis will be slow the first time it runs, as it needs to download additional dependencies.Figure 2 is an example of what this chart could look like. Your solution should show the data correctlybut doesnt need to be identical to this example.4Figure 2: Example of a JavaFX chart for the Advanced task.7 SubmissionThe final section of the README file for this coursework explains the submission process in detail. Pleasefollow the submission instructions carefully.The submission Process will generate a file named cwk1.zip containing your solution. Please remember tosubmit this file to Minerva, via the link provided in the Submit My Work section.The deadline for submissions is 10 am on Friday 5 March.Note that all submissions will be subject to automated plagiarism checking.8 Marking13 Tests for basic solution6 Tests for full solution5 ActiveCases program for full solution5 Advanced task (CovidChart program)4 Coding style and comments2 Use of version control请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导