CPT106 Friendship and Inheritance Assessment 2
1
CPT106 C++ Programming and Software Engineering II
Assessment 2
Assessment Number 2
Contribution to Overall Marks 15%
Submission Deadline Sunday, 2-May-2021, 23:59
How the work should be submitted?
SOFT COPY ONLY !
(MUST be submitted through Learning Mall so that the TAs can run your programs
during marking.) Make sure your name and ID are printed on the cover page of your
report.
Assessment Overview
This assessment aims at testing some basic concepts of C++ programming and initiates the routine of
code development using the software development process (SDP), namely the five main steps of the
software development process:
1. Problem statement: formulate the problem.
2. Analysis: determine the inputs, outputs, variables, etc
3. Design: define the list of steps (the algorithm) needed to solve the problem.
4. Implementation: the C++ code hasto be submitted as a separate file. Just indicate here the
name of the file.
5. Testing: explain how you have tested and verified your C++ program.
You will need to apply this methodology to each one of the following simple exercises.
What should be submitted?
A short report (up to a few pages of texts plus C++ source codes) detailing for all the questions of
the assignment. The answer for each question should follow the SDP method:
a) SDP steps 1 to 3. (30% of the total marks for that question)
b) SDP step 4 (implementation): your C++ source code including the comments. (40%)
c) SDP step 5 (testing): you will explain how you have tested the correctness of your C++
program and will include some sample runs of your C++ Programs. (20%). Testing
result must be shown by screenshot.
Besides, the overall quality of report will account for 10% of the total marks.
The report in PDF format together with the source code files of the whole C++ solution for all
questions should be zipped into a single file named with your own student ID number. (For
maintenance purposes, it is always a good practice to comment your code as you go. The
comments state the aim of the program, what are the inputs, what are the outputs, which
algorithm is used, who is the author and so on.)
CPT106 Friendship and Inheritance Assessment 2
2
EXERCISE 1 (7 POINTS OUT OF 15)
Derive a sub-class iFraction from the base class Fraction, which was designed by you in
Exercise 2 of Assessment 1. The iFraction class represents the mixed fractions like
1
3
5
Part 1:
1) Using operator overloading to rewrite all the operators defined forthe
Fraction class in the previous assignment if you have not done so.
2) Design the sub-class iFraction:
a. It should have a constructor for initialization;
b. It should contain a method to display the mixed fraction on screen;
Part 2: Design an external function convertF (notfunction member of class Fraction and
10 2
iFraction) to convert the improper fractions to mixed fractions, i.e., covert 6 to 1 3
.
Hint: convertF can be the friend function of those two classes.
EXERCISE 2 (8 POINTS OUT OF 15)
This is a computer game with different types of player. Take the code provided for the
container class (container.h), player class (player.h) and the swordsman class
(swordsman.h), and the main function (main.cpp).
Part 1:
1. Read the source codes, understand the meaning and fill the blank (shown
as) to make it work;
2. Then draw the hierarchy chart of above classes;
Part 2:
3. Design another two classes, archer and mage. Put them in the hierarchy chart
drew above. Write the code for these two classes and make them work
(cooperate with main function);
4. Modify main function, to have enemies with all three professions (couldbe
randomly chosen).
Part 3 (Optional):
5. Can you involve another attribute – luck, in this game?
Notes: The factors are imperfect, make the fight too hard or too easy. Change whatever
you want, but leave hints for reviewers to know what you have done.
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。