11/12/2020 CO3105/4203/7105 Assignment 2
CO3105/4203/7105 Assignment 2
Released Nov 16, 2020; Deadline Monday Dec 7, 2020 5:00 pm Deadline Wednesday
Dec 16, 2020 5:00 pm
This assignment is worth 30% of the module mark.
This assignment assesses your knowledge on inheritance and virtual functions, operator
overloading, and streams. You will need to know materials from weeks 16 - 17 (in
addition to basic concepts from earlier weeks).
Clarifications and amendments may be announced on the Blackboard discussion forum
for this assignment. You are expected to read the forum.
The Problem
You are going to implement a degree classification calculator for our BSc and MSc
degrees. (Sorry to students on MComp or other degrees. You are welcome to add more
subclasses to the program yourself of course...)
Student cohorts and the class hierarchy
As you know, BSc and MSc degrees are awarded to different classes, such as first class,
upper second class, etc for BSc, and Distinction, Merit, etc for MSc. The classification is
made according to a set of rules, based on the marks profile of a student. Each of BSc
and MSc have their own set of degree classification rules.
Additionally, a few years ago, the university revised and phased in a new set of degree
classification rules for BSc degrees. As a result, two cohorts of BSc students that are
governed by different rules will be graduating at the same time this year. (And this will
be the first and only year when a substantial number of new and old students graduate
together.)
Roughly speaking, BSc students entering as first years in 2018/19 are "new" students,
governed by new rules in place for the first time this year. Students entering in 2017/18
or earlier, but only reaching the third year now for various reasons such as spending a
year in industry, are "old" students governed by the old rules.
This naturally gives us a hierarchy of students, as represented in this diagram. The
following classes and the class hierarchy are declared for you in the given Student.h file.
Student
|
-------------------
| |
BScStudent MScStudent
|
--------------
| |
BScStudentOld BScStudentNew
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 1/6
11/12/2020 CO3105/4203/7105 Assignment 2
Modules, credits and marks
Each module has a module code, which is a 6-character string like "CO3105". The third
character in this string (3 in this case) indicates which year the module is for: 2 is for
BSc Year 2, 3 is for BSc Year 3, 7 is for MSc. (From now on we will abbreviate "Year 2"
and "Year 3" to Y2 and Y3.)
Each module has a fixed number of credits. Each BSc student is supposed to take
modules worth a total of 120 credits in each of Y2 and Y3, and each MSc student is
supposed to take 180 credits for the whole year, including a 60-credit project.
To avoid you (and me) repeatedly having to type in the number of credits of each
module, this information is contained in a data structure called MCT (short for Module-
Credit-Table), defined in the file Module.h. It includes all common modules that you will
encounter, as well as three "fake" modules (ending with FAK) for easier testing. The data
structure is a "map" from STL which we will only cover one week before the deadline.
Hence we included below all you need to know about it: it can be used like
string moduleCode = ...;
if(MCT.find(moduleCode) == MCT.end()) {
// if true, this means no module with that moduleCode is in MCT
}
// else it is in MCT
int credits = MCT.at(moduleCode);
// this returns the number of credits of this module, as stored in MCT.
// if no module with that code exists in the MCT it will throw an exception
All marks and averages are numbers of the float data type. You can assume (do not
need to check) that the marks are between 0.0 and 100.0 (inclusive).
The degree classification rules
Your actual degree classification rules are extremely complicated and are described in a
separate page.
Supported operations
The various student classes should support the following operations:
A constructor that takes the uid (a string) of the student as input.
bool addModule(string moduleCode, float mark): add the module with the
given module code and mark to the student. If the module code does not exist (is
not one of the given ones in Module.h), or if it is not for the correct year group for
the student (e.g. adding a level 7 module to a BSc Student), or if it is already
added, or if adding this exceeds the total credit for the relevant year of the degree,
return false and do not add the module. Otherwise, return true.
bool updateMark(string moduleCode, float mark): update the module mark
with that module code for this student with the given mark. The module should
have been added to this student previously; if no such module code has been added
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 2/6
11/12/2020 CO3105/4203/7105 Assignment 2
to the student before, or if the module code does not exist, return false and do not
change anything. Otherwise, return true.
float y2cwa(): return the Year 2 credit-weighted average of the student, based on
the modules added so far. In other words, if less than 120 credits of modules have
been added, it should still calculate an average based on those modules added. If
no modules have been added so far, return 0. This function only applies to
BScStudent (and its subclasses).
float y3cwa(): same as above except this is for Year 3.
float cwa(): return the overall credit-weighted average, based on all modules
added so far. For BScStudent this is a combined average of the Y2 and Y3 CWA
(according to specific rules for BScStudentOld or BScStudentNew). For MScStudent
this is simply the credit-weighted average of all modules. Again, if no modules have
been added so far, return 0.
string calcDegClass(): return a string containing the calculated degree class. It
should be one of:
For BSc: "FIRST CLASS", "BORDERLINE FIRST CLASS", "UPPER SECOND
CLASS", "BORDERLINE UPPER SECOND CLASS", "LOWER SECOND CLASS",
"BORDERLINE LOWER SECOND CLASS", "THIRD CLASS", "PASS", and "FAIL".
For MSc: "DISTINCTION", "MERIT", "PASS", and "FAIL".
The full amount of credits must be entered before degree classification rules can be
applied. If insufficient credits are entered, it should return the string "INSUFFICIENT
CREDITS".
In addition, there are two overloaded stream operators. They are to be implemented as
friend functions (not as member functions of any class):
istream& operator>>(istream& is, Student& student): the overloaded >>
operator that reads module and mark information from the input stream to the
student object. Each line in the stream consists of a string (the module code) and a
float (the mark of the module), separated by a space. Each such module read in
should be added to this student, according to all the conditions in addModule(). In
cases where addModule() would have returned false, you don't need to return any
kind of error information here; just ignore that module and quietly move on to the
next one. You should read until the end of the stream. You can assume the stream
data will conform to the above specification, so no input error handling is needed.
ostream& operator<<(ostream& os, const Student& student): output the
following to the output stream: the student's uid, followed by a tab character ('\t'),
following by the degree classification as returned by calcDegClass().
Further details of what exactly each function should do is in the Student.h and various
[BSc|MSc]Student[Old|New].cpp files. (We defined all classes in a single header file, but
each class has its own .cpp file.)
In all calculations, you can ignore the issue of floating point inacuracy. For example,
comparisons with >, >= etc. can be applied directly like if (cwa() >= 69.5) ...
What can be / need to be changed
The classes Student, BScStudent, BScStudentNew, BScStudentOld, and MScStudent, as
well as their inheritance relationships, have been defined for you. However, all the
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 3/6
11/12/2020 CO3105/4203/7105 Assignment 2
required member functions are only declared in the highest class in the class hierarchy
where they are relevant. You will need to decide whether some subclasses should
override some of the functions, where in the hierarchy should they be implemented, and
whether each function should be made virtual.
In addition, all non-leaf classes should be abstract; only instances of BScStudentNew,
BScStudentOld and MScStudent should be allowed to be created. This means each non-
leaf class must have some pure virtual member functions, so you will need to decide
where to use the = 0 pure specifier.
You must not change the existing public interface of the class, other than in relation to
inheritance, virtual-ness and pure-ness as explained above. You are allowed to add
public/protected/private member functions, should you want to.
You will also need to decide what protected/private data members to add to some of the
classes. You can either use basic data types such as arrays, or STL containers if you
wish. If you need to, you can assume some maximum limit on the number of modules a
student may take (such as the constant MAX_MODULES defined in Student.h; you can
remove these constants if you don't need them).
Files Provided
Student.h
Student.cpp
BScStudent.cpp
BScStudentOld.cpp
BScStudentNew.cpp
MScStudent.cpp
These are the only files you need to modify/submit. All code written by you should be in
there.
Module.h
The file that contains the module credit info. You need this file to compile the programs.
You should not modify this file.
main.cpp
This is just an example that illustrates how the functions can be called.
StudentTester.h
StudentTester.cpp
StudentTesterMain.cpp
teststudent1.txt
teststudent2.txt
teststudent3.txt
They are used for the execution testing part (see the next section). The three txt files
are needed for some of the test cases.
makefile
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 4/6
11/12/2020 CO3105/4203/7105 Assignment 2
This is a makefile that will compile the main executable and the testing suite executable.
Marking Criteria and Test Suites
See this separate page for the marking criteria.
To use the test suite (which is used in the execution testing part of the marking), simply
type "make" in a linux terminal (with all the above files in the same folder). It will
(assuming you did not break the given .h and .cpp files) produce a StudentTesterMain
executable file. Run the program by typing
./StudentTesterMain a
or
./StudentTesterMain a b c d
which runs a single test case or multiple test cases respectively. We will also demonstrate
its use in class.
The test suite may not cover all corner cases, so passing all test cases does not
guarantee your program is 100% correct. Also, unfortunately we cannot isolate the
testing of the various functions. For example to pass those test cases meant for cwa()
you need to also implement addModule() at least partially correctly.
Submission Instructions
Submit your completed work on Blackboard ("Assessment and Feedback" on the left,
then "Assignment 2").
Submit only the files Student.h, Student.cpp, BScStudent.cpp, BScStudentOld.cpp,
BScStudentNew.cpp and MScStudent.cpp. Just upload them as separate files (contrary to
earlier version of this page, DO NOT zip them). Please note the linux file system is case-
sensitive. DO NOT change the upper/lowercase of filenames. If you do, it will not work
with the makefile/test suite and a penalty will be applied.
Optionally, if you want to change the makefile (for example to use C++17) you can
submit a revised makefile. Otherwise I will use the one I supplied. Your revised makefile
must still work on the departmental linux system. In particular it has g++ version 9.3.0,
which by default uses C++14 but it supports "most" of C++17 and you can change the
compiler flag to tell it to use that.
Do not upload the entire project folder of whatever IDE you are using. While you may
want to change the main.cpp file for your own testing, it is not part of the submission.
The test suites also should not be submitted. If you submit them, they will be ignored
and I will use my own version for testing.
This is an individual assignment, and collaboration is not permitted. Plagiarism will be
treated strictly according to standard university and departmental procedures. Your
submissions may be sent to a plagiarism detection service (MOSS).
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 5/6
11/12/2020 CO3105/4203/7105 Assignment 2
Anonymous marking is achieved by having only the userid / student number visible in
your submission.
For the above two reasons, do not include your name or any personally identifible
information in your programs.
https://blackboard.le.ac.uk/bbcswebdav/pid-2570756-dt-content-rid-9773075_2/courses/CO3105_2020-21_SEM1/Asg/cw2/cw2.html 6/6