CSCI 1110 分析求解

CSCI 1110 – Fall 2020

Assignment 04 – Due 11/04, 11 pm

Please start this assignment early; programming and logic take time - if you leave it to the last

minute, you might not have enough time to finish or might make silly mistakes that you otherwise

could avoid. Note that TAs and Instructors will not be able to answer last-minute questions!

All work is to be handed in Mimir, our online code learning environment. You should, however,

write your code on an IDE such as IntelliJ.

To complete this assignment, you will need to know about:

• Basic Java

• Conditionals

• Boolean Variables

• Loops

• Objects and Classes

• Java Collections Framework (Lists, Sets, Maps, Queues, Stacks)

Your code must compile. If it does not compile, you will receive a 0 (zero) on that portion of the

assignment, and no partial marks will be given.

Remember that students who hardcode their outputs to match the test cases in Mimir will

receive a zero on the entire assignment.

Grading Scheme: Please see the grading scheme at the end of this document.

Coding Style: You must proper variable names and comments. Please follow the guidelines on

https://web.cs.dal.ca/~franz/...

Problem Overview

In this assignment, you will finish implementing a set of classes used to represent Students,

Courses and a University.

This assignment is meant for you to write code using the JFC collections (lists, sets, maps,

queues, etc.) and their built-in algorithms (e.g., contains method). Your goal is to read through

the already written javaDocs and fix the variable declarations and methods flagged with a ToDo

comment (//TODO).

You can create other private methods and variables if you want, but you don't have to. You also

don't have to add any more JavaDocs; however, inline comments are still required on the

methods you write code on.

The two classes you have to work in are University.java and Student.java.

Iterators on Maps

We discussed iterators in lectures 14 and 15. Iterators are what a foreach loop uses

"underneath the surface." We also explored how to retrieve an iterator from a List and use it to

iterate over (and even remove) the collection using while loops.

You cannot get an iterator from a map directly since the stored information is associated with a

tuple of keys and values. To iterate on a map, you have to get the keys from the map and

iterate over them. Example:

• Assume that you have a map that associates Farms and Cows (). The keys to

the map are Farm objects.

• You can retrieve the keys already on the map by calling the keySet() method on the map

variable. It will return a set of keys (Set). You can then get the iterator of a set

the same way you do for lists.

o Another way to go over every element on the map is to use the values() method

on the map variable. This method will return a Collection.

o It is up to you to chose which path you want to follow

For the curious among you

I added some extra code in the Student and Course classes:

• StringBuilder: we should use a SB to concatenate strings on loops instead of +=

because everytime we are using += we are instantiating a new String (they are

imutable)

• Saving and loading objects to a binary file (Student class): you can write another

class on your computer to toy with those two methods.

Grading Scheme

Each problem on the assignment will be graded based on three criteria:

Functionality

"Does it work according to specifications?" This is determined in an automated fashion by

running your program on a number of inputs and ensuring that the outputs match the expected

outputs. The score is determined based on the number of tests that your program passes.

Quality of Solution

"Is it a good solution?" This considers whether the solution is correct, efficient, covers boundary

conditions, does not have any obvious bugs, etc. This is determined by visual inspection of the

code. Initially full marks are given to each solution and marks are deducted based on faults

found in the solution.

Code Clarity

"Is it well written?" This considers whether the solution is properly formatted, welldocumented,

and follows coding style guidelines

你可能感兴趣的:(后端)