CSCI 2134 Assignment 3
Due date: 11:59pm, Friday, March 19, 2021, submitted via Git
Objectives
Practice debugging code, using a symbolic debugger, and fixing errors.
Preparation:
Clone the Assignment 3 repository
https://git.cs.dal.ca/courses/2021-winter/csci-2134/assignment3/.git
where is your CSID.
Problem Statement
Take a piece of buggy code, debug it, and fix it.
Background
You have inherited some buggy code for computing shortest path solutions to the board game
Ticket to Ride. Your boss has fired the previous developer because they did not do any testing
and did not fix the bugs! She has hired you to debug and fix the code. She will provide you with
some unit tests (some of which fail), sample input and sample output of what should be produced.
Your job is to fix the bugs: Both the bugs exhibited by the unit tests and the ones by the
input. Good luck!
目标
使用符号调试器练习调试代码,并修复错误。
准备:
克隆工作分配3存储库
https://git.cs.dal.ca/courses/2021-winter/csci-2134/assignment3/.git
您的CSID在哪里。
问题陈述
截取一段错误的代码,对其进行调试,然后进行修复。
背景
您已经继承了一些错误的代码,用于计算棋盘游戏的最短路径解决方案
乘车票。您的老板已解雇了以前的开发人员,因为他们没有进行任何测试
并没有修复错误!她雇用了您调试和修复代码。她会为您提供
一些单元测试(其中一些失败),应产生的样本输入和样本输出。
您的工作是修复错误:单元测试中显示的错误以及单元测试中显示的错误。
输入。祝你好运!
您将获得一个完整的越野车代码库,用于JSON比较,一个规范和一组单元
使用JUnit5进行测试,样本输入和预期输出。您的工作是识别并修复所有错误。
给定一个由铁路线组成的游戏板和一条路线清单(成对的城市),该代码应该能够
假设最短路径,计算在给定路径之间建立网络的总成本
选择每条路线的距离。这可以通过计算每个的最短路径来计算
使用Dijkstra的最短路径算法进行路线。
您将获得一个完整的越野车代码库,用于距离计算,一个规范,一组
使用JUnit5的单元测试,样本输入和预期输出。您的工作是识别并修复所有问题
错误。
任务代写CSCI 2134程序
1.在docs目录中查看规范(specification.pdf)。你绝对会
需要了解它以及您正在调试的代码。程序的主要方法
在RouteCost.java中。请注意,您的老板终于在中获得了有问题的makeTree方法
来自先前开发人员的City.java。花一些时间跟踪代码并创建
类和代码如何组合的示意图。以后对您有很大帮助!
2.修复以下类中由单元测试生成的测试标识的所有错误:
•City.java
•CityComparator.java
•Link.java
3.请参阅docs目录中的buglist.txt文件。其中包括一个示例条目。对于每个错误
您修复的问题将添加到此文件的条目,其中包括:
一种。错误所在的文件/类名。
b。错误所在的方法
C。错误代码所在的行号
d。有关错误的描述
e。有关修补程序的说明。
4.先前的开发人员在input_tests中提供了一组示例输入和预期输出
目录。即使修复了已确定的错误,这些测试仍可能无法通过
通过单元测试。
•有关运行测试的帮助,请参见此目录中的README.txt。最简单的方法是
将.java文件从src复制到此目录,然后在终端或git中运行test.sh脚本
bash命令行外壳。
•将.out文件中的输出与预期的.gold文件进行比较。
•对于与预期输出不同的每个输出,请调试代码并确定
不匹配的原因。修复单元测试遗漏的所有已识别错误。
5.在先前创建的buglist.txt中记录在步骤4中发现并修复的所有新错误。
6.提交错误修复和buglist.txt文件并将其推回远程存储库。
提交
必须提交所有修复程序和文件,并将其推送回远程Git存储库。
等级
将使用以下分级方案:
任务4/4 3/4 2/4 1/4 0/4
发现错误
You will be provided with a full buggy codebase for JSON comparison, a specification, a set of unit
tests using JUnit5, sample input and expected output. Your job is to identify and fix all the bugs.
Given a game board of rail segments and a list of routes (pairs of cities), the code is supposed to
compute the total cost of building a network between the given routes, assuming that the shortest
distance for each route is chosen. This can be computed by computing shortest paths for each
route using Dijkstra’s shortest path algorithm.
You will be provided with a full buggy codebase for distance computation, a specification, a set
of unit tests using JUnit5, sample input and expected output. Your job is to identify and fix all
the bugs.
Task
1. Review the specification (specification.pdf) in the docs directory. You will absolutely
need to understand it and the code you are debugging. The main method for the program
is in RouteCost.java. Note that your boss finally got the buggy makeTree method in
City.java from the previous developer. Spend some time tracing through the code and creating
a diagram of how the classes and code are put together. This will help you a lot later on!
2. Fix all bugs that are identified by the tests generated by the unit tests in the following classes:
• City.java
• CityComparator.java
• Link.java
3. See buglist.txt file in the docs directory. One sample entry is included. For each bug
that you fix add an entry to this file that includes:
a. The file/class name where the bug was.
b. The method where the bug was
c. The line number(s) where the buggy code was
d. A description of what the bug was
e. A description of what the fix was.
4. The previous developer made a set of example input and expected output in the input_tests
directory. These tests will likely not pass yet even after fixing the bugs identified
by the unit tests.
• See the README.txt in this directory for help running the tests. The easiest method is to
copy your .java files from src to this directory and run the test.sh script in a terminal or git
bash command line shell.
• Compare the output in the .out files with the expected .gold files.
• For each output that differs from the expected output, debug the code and determine
the reason for the mismatch. Fix any identified bugs missed by the unit tests.
5. Record any new bugs found and fixed from Step 4 in the previously created buglist.txt
6. Commit and push back the bug fixes and the buglist.txt file to the remote repository.
Submission
All fixes and files must be committed and pushed back to the remote Git repository.
Grading
The following grading scheme will be used:
Task 4/4 3/4 2/4 1/4 0/4
Bugs found
[unit tests]
(20%)
4 to 5 bugs are
correctly identified
and documented.
Three (3) bugs
are correctly
identified and
documented.
Two (2) bugs
are correctly
identified and
documented.
One (1) bug is correctly
identified
and documented.
Zero (0) bugs
are correctly
identified and
documented.
Bugs fixed
[unit tests]
(20%)
4 to 5 bugs are
correctly fixed.
All unit tests
pass.
Three (3) bugs
are correctly
fixed.
Two (2) bugs
are correctly
fixed.
One (1) bug is correctly
fixed.
Zero (0) bugs
are correctly
fixed.
Bugs found
[input tests]
(20%)
2 to 3 bugs are
correctly identified
and documented.
N/A One (1) bug is
correctly identified
and documented.
N/A Zero (0) bugs
are correctly
identified and
documented.
Bugs fixed
[input tests]
(30%)
2 to 3 bugs are
correctly fixed.
All input tests
pass.
2 to 3 bugs are
correctly fixed.
One (1) bug is
correctly fixed.
Some input
tests pass
N/A Zero (0) bugs
are correctly
fixed.
Document
[buglist.txt]
Clarity
(10%)
Document
looks professional,
includes
all information,
and easy to
read
Document looks
ok. May be
hard to read or
missing some
information.
Document is
sloppy, inconsistent,
and has
missing information
Document is very
sloppy with significant
missing information
Document is
illegible or not
provided.
Hints
1. You will need to use a symbolic debugger to make headway. Using print-statements will be
possible but extremely painful.
2. You will need to step through the code to find the bugs.
3. There are about 2-3 bugs in the code (in addition to the ones identified by the unit tests). The
single bug report should cover all of them.
如有需要,请加QQ:99515681 或WX:codehelp