Java代写:INFO1105 Submission History

代写Java作业,实现题目要求的SubmissionHistory接口,并通过测试。

Specification of the coding

Description

You will write the code for a class Assignment which implements the SubmissionHistory interface. This interface describes a system for keeping track of student assignment submissions.

The SubmissionHistory interface

SubmissionHistory objects allow you to keep track of Submission objects. The SubmissionHistory interface has the following methods:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Find the highest grade of any submission for a given student
public Integer getBestGrade(String unikey);

// The most recent submission for a given student
public Submission getSubmissionFinal(String unikey);

// The most recent submission for a given student, prior to a given time
public Submission getSubmissionBefore(String unikey, Date deadline);

// Add a new submission (can assume submissions from one student have different times)
public Submission add(String unikey, Date timestamp, Integer grade);

// Remove a submission (can assume submissions from one student have different times)
public void remove(Submission submission);

// Get all the students who have the highest grade
public List<String> listTopStudents();

// Get all the students whose most recent submission has lower grade than their best submission
public List<String> listRegressions();

For all of the interface methods, if any of the arguments passed to the method are null, then you should throw new IllegalArgumentException();

The full skeleton code for the assignment (with more detailed comments than those given here) is available for download on the resources section of Ed, and is also listed in the appendix.

Think carefully about which data structure(s) are most suitable. A simple solution can work correctly (and get reasonable marks) but for efficiency, you may find it useful to store data in more than one data structure or to nest structures.

To achieve maximum marks, your solution should be efficient. All methods should run in sub-linear time (i.e. better than O(n), where n is the number of submissions. You can still get good marks (i.e. a credit) for simpler, less efficient solutions (provided that they are correct, and are correctly analyzed).

Exceptions:

  • listRegressions should be better than O(n^2) time
  • listTopStudents should be better than O(n) time, with the assumption that the number of students being returned is sub-linear.

Submission objects

Each Submission object has a unikey (String), a timestamp (java.util.Date), and a grade (Integer). You may assume that Submission objects are immutable. That means that once an submission has been added, it cannot be modified (but it could be removed.) You may assume that no student will have multiple submissions with the same timestamp. You may assume that any Submission object has non-null values for its three fields.

Example

Suppose we added the following submissions: 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
SubmissionHistory history = new SubmissionHistory ();
history.add("aaaa1234", df.parse("2016/09/03 09:00:00"), 66); //submission A
history.add("aaaa1234", df.parse("2016/09/03 16:00:00"), 86); //submission B
history.add("cccc1234", df.parse("2016/09/03 16:00:00"), 73); //submission C
history.add("aaaa1234", df.parse("2016/09/03 18:00:00"), 40); //submission D

// This will return an Integer corresponding to the number 86
Integer example1 = history.getBestGrade("aaaa1234");

// This will return null
Integer example2 = history.getBestGrade("zzzz1234");

// This will throw new IllegalArgumentException();
Integer example3 = history.getBestGrade(null);

// This will return a Submission corresponding to submission D
Submission example4 = history.getSubmissionFinal("aaaa1234");

// This will return a Submission corresponding to submission C
Submission example5 = history.getSubmissionFinal("cccc1234");

// This will return a Submission corresponding to submission A
Submission example6 = history.getSubmissionBefore("aaaa1234", df.parse("2016/09/03 13:00:00"));

// This will return null
Submission example7 = history.getSubmissionBefore("cccc1234", df.parse("2016/09/03 13:00:00"));

// This will return a list containing only {" aaaa1234 "}
// because that student's final submission had grade 40, but their best was 86
List<String> example8 = history.listRegressions();

// This will return a list containing only {" aaaa1234 "}
// because that was the only student with the highest grade
List<String> example9 = history.listTopStudents();

// If we added another student with the same highest mark, they would both be returned
// If we instead removed submission B, then {"cccc1234"} would become the top student

Marking

Code automarking

Part of the marking of your code will be done automatically on Ed. You are encouraged to submit early and often - there is no penalty for making multiple submissions.

There will be some visible tests to help you verify that your solution is configured correctly. The remaining test cases will be invisible until after the submission deadline. Test your code carefully to ensure that your solution works correctly. The score on this component will be based on the number of tests passed. If you pass every visible test, you will get at least half of the available marks.

Code hand marking

Part of the marking of your code will be done by hand. We will grade your code on its readability and overall quality. Your code should be well laid out, with appropriate use of whitespace. Comments should be used where it makes your code easier to understand. Variables and methods should be named appropriately. If appropriate, helper methods should be used to avoid duplicating code, and to make any very complex methods easier to understand.

To gain half the marks for this component, your code needs to be understandable without great effort by a reader. Three-quarters of the marks for this component would be awarded for code where, in addition, the design makes some of the methods efficient, and where the structures used are adequately documented in the code itself, and also you have written a set of tests (besides those we provided) that check for the main aspects of correctness of several of the public methods. To get full marks, your design needs to make every method efficient, and it must still be easy to understand, and also you have written a very thorough set of tests (besides those we provided) that check for correctness of all the public methods.

Note that if you have a complicated efficient design, and it is not easy to understand, then you will get less than half the marks.

Report

You should write a brief report (please try to keep it under 1 page). The report should include the following:

  • A high level overview of your implementation (one paragraph, or bullet points.)
  • For each data structure used, state what you used it for (one paragraph each, or bullet points.)
  • List each method from the description, stating the running time in big-Oh notation, and giving a brief justification (for example, a justification could say how often various methods of the underlying data structure are called, and what is the big-Oh cost of each call).

An easy-to-read report that gives correct running times for the methods, with reasonable justification, will gain at least half the marks for this component. To gain three-quarters of the marks on this component, you should also have a design where several of the methods are efficient. To gain full marks for this component, you should also have a design where every method is efficient.
Note that if you have a complicated design, and do not analyse its methods correctly, then you will get less than half the marks.

Report

You should write a report (please try to keep it under 3 pages). The report should include the following:

  • A high level overview of your implementation (one paragraph, or bullet points.)
  • For each data structure used, state what you used it for and why (one paragraph each, or bullet points.)
  • List each method from the description, stating the running time in big-Oh notation, and giving a brief justification (for example, a justification could say how often various methods of the underlying data structure are called, and what is the big-Oh cost of each call).
  • A discussion that compares your design to an alternative design thast you considered, and explains the advantages and disadvantages of each of these two approaches. (1-2 pages)

The first three aspects will be scored out of 30, using the same scheme as for the undergraduate students. That is: An easy-to-read report that gives correct running times for the methods, with reasonable justification, will gain at least half the marks for this component. To gain three-quarters of the marks on this component, you should also have a design where several of the methods are efficient. To gain full marks for this component, you should also have a design where every method is efficient. Note that if you have a complicated design, and do not analyse its methods correctly, then you will get less than half the marks.

The fourth aspect (the discussion of the comparison with an alternative design) will be scored out of 10. To get half the marks, you need to present an alternative design that could work correctly, and identify one substantial advantage of the design you actually coded. For three-quarters of this aspect, you need to also identify one valid disadvantage of the design you coded. For full marks, you need a reasonable and balanced discussion that shows a good understanding of the alternatives and their implications.