CSCI 1110 分析求解

码海探雪使
• 阅读 209

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 (<Farm,Cow>). 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<Farm>). 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<value>.

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
WX:codehelp

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
6个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Wesley13 Wesley13
3年前
VBox 启动虚拟机失败
在Vbox(5.0.8版本)启动Ubuntu的虚拟机时,遇到错误信息:NtCreateFile(\\Device\\VBoxDrvStub)failed:0xc000000034STATUS\_OBJECT\_NAME\_NOT\_FOUND(0retries) (rc101)Makesurethekern
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Stella981 Stella981
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Easter79 Easter79
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa
Wesley13 Wesley13
3年前
Java日期时间API系列36
  十二时辰,古代劳动人民把一昼夜划分成十二个时段,每一个时段叫一个时辰。二十四小时和十二时辰对照表:时辰时间24时制子时深夜11:00凌晨01:0023:0001:00丑时上午01:00上午03:0001:0003:00寅时上午03:00上午0
Wesley13 Wesley13
3年前
MBR笔记
<bochs:100000000000e\WGUI\Simclientsize(0,0)!stretchedsize(640,480)!<bochs:2b0x7c00<bochs:3c00000003740i\BIOS\$Revision:1.166$$Date:2006/08/1117