Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Assignment 1: Java finger exercises ► Assignment 1: Java finger exercises 1  Purpose 2  Getting started 3  Adding a class 4  Adding a method 5  Grading standards 6  Submission Assignment 1: Java finger exercises 1 Purpose 2 Getting started 3 Adding a class 4 Adding a method 5 Grading standards 5.1 The style guide 6 Submission 6.1 Deliverables 6.2 Instructions 7.5 Assignment 1: Java finger exercises Due:Tue 09/17 at 8:59pm; self-evaluation due Wed 09/18 at 9:59pm Starter files: code.zip 1 Purpose The primary goal of this assignment is to get you writing Java (again or for the first time). As a secondary goal, completing this assignment will help you ensure that you have a properly configured and working Java development environment and IDE, and that you can use the submission system (to be described elsewhere). 2 Getting started Before you start this assignment, you should make sure that you’ve set up a proper CS 3500 environment. You can view the accompanying video tutorial for more help. We are using the Java SE Development Kit 11 toolchain (JDK 11), which is the latest Long-Term Support version of the language. Do not use Java 12, even though it’s newer; the handin server does not and will not support it, and you shouldn’t inadvertently use features that you’ll then have to rewrite. You need a good Java IDE. We recommend IntelliJ IDEA, but you may use whatever IDE you like. We strongly recommend that you install Git if you don’t already have it. Once you’ve installed JDK 11, Git, and an IDE, you probably need to tell the IDE where to find the JDK and Git. Additionally, you should configure your IDE to set your Java language level to 11—this is a separate configuration step. We will be taking full advantage of Java 11 in this course. Finally, you also need to configure your IDE with the appropriate style settings: see The style guide below. Get the code for this homework assignment using the “Starter files” link above. Take a look at the provided code: The code from Lecture 2 appears in src/cs3500/hw01/publication, with tests in test/cs3500/hw01/publication. File test/Hw01TypeChecks.java contains a small class designed to help you detect when your code may not compile against the grading tests. In particular, if including test/Hw01TypeChecks.java—unmodified, in that directory!—in your project produces compilation errors, then it won’t compile for the course staff either. 3 Adding a class This part of the assignment is a continuation of the code written in Lecture 2: The essence of objects. In particular, you will design a Java class ConferenceProceedings (in package cs3500.hw01.publication) that implements the Publication interface from lecture. Design a class ConferenceProceedings that implements the Publication interface. It must define a public constructor: public ConferenceProceedings(String editorLastName, String editorFirstName, String title, String location, int year, String publisher) The signature of the constructor, including the order of the arguments, is important to enable automated-test–based grading for functional correctness. Don’t forget to write a good Javadoc comment. Note: See how to cite a conference proceedings in MLA and APA style by looking at Purdue’s Online Writing Lab — conferences are mentioned as “other common sources”. You are expected to use some common sense in deciphering what the various parts of the citation are; if some information appears to be missing from the constructor above, you do not need to include it in your citation, but leave a comment in your code explaining what if anything you left out. Note: You do not need to wrap your output onto multiple lines, as shown on the OWL webpage; a single, very-long line is fine. Note: The constructor above, as defined, only allows for a single publication editor. You do not need to support multiple editors. Write a JUnit 4 test class, ConferenceProceedingsTest, that tests both public methods of ConferenceProceedings. 4 Adding a method Compared to the version from class this week, there are two changes in the code for this homework: Interface Duration now has an additional method, format(String), along with a Javadoc comment detailing its specification. Class AbstractDurationFormatTest contains two simple test methods for format, called formatExample1 and formatExample2. These serve as examples, and you will need to add several more to have good test coverage. Add tests for format only to this class, or else the autograder will not work properly. To complete this assignment: You must write sufficient tests to be confident that your implementation of the format method is correct. Your tests should exercise every non-trivially distinct possibility. It is recommended that you write these tests before attempting to implement the format method as specified below. Doing so will help you clarify how the method is supposed to work. The autograder for this portion of the homework is slightly tricky, and requires your code to be designed in a particular way. First, your tests must be placed in the AbstractDurationFormatTest class, and you must leave unchanged the portion of the file marked "Leave this section alone". Second, do not explicitly use new in your tests: as we did in class, use the wdh and hours methods to construct examples of Durations. The autograder will run your tests against several new Duration classes with deliberately-buggy format implementations, and against one perfectly-correct implementation; to earn full credit on this autograder, you must have sufficient tests to catch all of these bugs. In other words, you will succeed on this homework if you write enough correct tests to comprehensively check the format method, such that at least one fails on any buggy implementation of it, but all tests pass on the correct implementation. Remember: test failures are good things! You must implement the Duration.format(String) method in the appropriate place(s). Your implementation must not use any of the string replacement methods such as replace or replaceAll. (We strongly suggest that you use iteration and not recursion to process a string.) The Javadoc description of this method is a sufficient specification for this method, but requires careful attention: an overly-hasty reading will probably miss some edge cases. The autograder will also test your implementation for correctness, regardless of whether you wrote your own test cases. 5 Grading standards For this assignment, you will be graded on whether your code compiles, whether your code implements the specification (functional correctness), whether you thoroughly test every method that you write, and how well you follow the style guide. 5.1 The style guide Coding style is important. For this class we follow Google’s Java style guide. It’s comprehesive but not very long, so I suggest reading the whole thing and then referring to it as needed. While it can’t yet take on full responsibility for formatting code—much less for programming style more broadly—your IDE may be able to help you follow the code formatting portion of the style guide: For Intellij IDEA, download intellij-java-google-style.xml and save it in the config/codestyles/ subdirectory of your IntelliJ configuration folder. Then from within IntelliJ, go to File > Other Settings > Default Settings..., then in the dialog that pops up, go to Editor / Code Style, and select it in the Scheme dropdown, where it should have appeared as an option. If you’ve already created a project, then you’ll additionally need to set this as the project style, using File > Settings. For Eclipse, download the eclipse-java-google-style.xml. Under Window > Preferences, select Java / Code Style / Formatter and import the settings. Check here for more info. 6 Submission 6.1 Deliverables Your submission should include ConferenceProceedings.java, ConferenceProceedingsTest.java, and any files you had to modify or create in order to implement and test your format(String) method. Please ensure that your submission is a zip file. This zip file should contain your src/ and test/ folders from your project, and only those folders. These folders should mimic the folder structure required for your packages (e.g. for a class inside cs3500.hw01.duration, the src/ folder should contain a cs3500/ folder, inside which is a hw01/ inside which is a duration/ folder). Please do not put these folders within another folder before submitting, as the grader will not find your files. Good Bad my-submission.zip +-src/ | +-cs3500/ | +-hw01/ | +-duration/ | | +-Java files for durations | +-publication/ | +-Java files for publications +-test/ +-whatever tests you wrote... possibly in packages... my-submission.zip +-My Awesome Homework 1/ +-src/ | +-cs3500/ | +-hw01/ | +-duration/ | | +-Java files for durations | +-publication/ | +-Java files for publications +-test/ +-whatever tests you wrote... possibly in packages... 6.2 Instructions You will submit your homework at https://handins.ccs.neu.edu. We have written a how-to guide for using the handin server, if you are unfamiliar with it. (To log in to the handin server, you will need an active CCS account. If you are a CS major or have taken a CS class before, you should have one already. If you have forgotten your account name or password, go to https://my.ccs.neu.edu/ and click on the “Forgot Username” or “Forgot Password” links. Once logged in, you will need to enter some simple profile information (NUID, name and nickname, mostly), and upload a picture of yourself so we recognize you. After completing that profile, you’ll be taken to a page like this one: In this screen: The navigation bar at the top will take you to this homepage via the Bottlenose icon, to your profile via your nickname, and to a list of your currently enrolled courses. You can also log out. Arranged by semester, you can see your current courses, and your homeworks and teams within them. In the homework area, you have links to all currently available homeworks, along with basic information about them. The score bubbles to the right show each of your submissions for that assignment; the green one is the one being graded. Clicking on a homework link will take you to a page where you can see all your submissions in more detail, as well as create a new submission. Note: For assignments with autograders, it may take a little while for the grade to appear; in the meantime it will appear as “Missing”. Do not panic!