Assignment 3
1 Submission Instructions
Submit to Brightspace on or before the due date a compressed file (.tar or .zip) that includes
1. Header and source files for all classes instructed below.
2. A working Makefile that compiles and links all code into a single executable. The Makefile should be specific
to this assignment - do not use a generic Makefile.
3. A README file with your name, student number, a list of all files and a brief description of their purpose,
compilation and execution instructions, and any additional details you feel are relevant.
2 Learning Outcomes
In this assignment you will learn to
1. Add functionality to an existing codebase.
2. Change a class implementation while keeping the same interface
3. Make a UML diagram to illustrate the interaction between classes.
4. Implement copy constructors that use deep copy, while properly managing all dynamic memory.
5. Implement proper encapsulation (using the const keyword where appropriate)
VERY IMPORTANT!!! YOU WILL LOSE MARKS IF YOU DO NOT CONST YOUR FUNC TIONS AND PARAMETERS!!!.
3 Overview
This is a continuation of the GetHub project from assignment 2. As a starting point, you may use your own assignment,
or use the code provided.
In addition to changing existing classes, you will implement a Client class that can “download” (i.e., make a
deep copy of) a Repo, and then print the Files it contains.
As before there is a Control class that connects and coordinates the functionality of your classes with a View
class. In addition there is a separate TestControl class that allows you to run tests.
You will be required to make a UML diagram of the completed project.
4 UML Diagram
Make a UML diagram of the completed project. You may omit the Control, TestControl, Tester, and View classes.
A partial UML diagram is provided to help you get started. It includes the “uses” notation, which we did not discuss
in class, but this is the only place in the diagram where this particular notation should appear.
COMP2404 -“Introduction to Software Engineering”
Assignment 3
GetHub
// add, remove, get
+ addRepo(in title: string, in owner: string)
+ deleteRepo(in index: int)
+ getNumRepos(): int
+ download(in index: int, out repo: Repo): bool
+ addFile(in repo: string, in title: string, in content: string, in date: Date)
+ addFile(in repo: int, in title: string, in content: string, in date: Date)
+ deleteFile(in repo: int, in file: int)
+ printRepos()
+ printRepo(in index: int)
+ printFileContents(in repoIndex: int, in fileIndex: int)
Client
+ cloneRepo(in getHub: GetHub, in index: int)
+ printRepo ( )
+ printFileContents(in index: int)
uses
COMP2404 -“Introduction to Software Engineering”
Assignment 3
5 Classes Overview
This application will consist of 11 classes. Ten classes are provided: these are the same classes from Assignment 2.
You will add another class and make changes to some of the existing classes.
1. The Date class (Entity object):
(a) Contains date information.
2. The File class (Entity object):
(a) Contains information about the File (name, content, last date modified)
3. The Repo class (Entity object):
(a) Contains information about the Repo (title, owner)
(b) Manages a collection of Files
4. The FileList class (Collection object):
(a) Data structure for File pointers.
5. The RepoList class (Collection object):
(a) Data structure for Repo pointers.
6. The GetHub class (Control, Collection, View object):
(a) Manages a collection of Repos.
(b) Provides services to add, delete, access, and print Repos and the Files in the Repos.
(c) Prints (error) messages to std::cout
7. The View class (Boundary object):
(a) Presents a menu, takes input from the user
8. The Control class (Control object):
(a) Manages the interaction of the other objects.
9. The TestControl class (Control object):
(a) Manages the interaction of the other objects in order to run tests.
10. The Tester class (???):
(a) Provides testing functionality.
We will be using std::cout as the main output object for error reporting.
COMP2404 -“Introduction to Software Engineering”
Assignment 3
6 Instructions
Download the starting code from Brightspace. It includes some global functions that you are to use for testing as
well as some classes. All member variables are private unless otherwise noted. All member functions are public
unless otherwise noted. Some return values are not explicitly given. You should use your best judgment (they will
often be void, but not always). ALL CLASSES MUST HAVE A PRINT FUNCTION (except for FileList and
RepoList). This print function should display the metadata of the class using appropriate formatting.
Your finished code should compile into two executables called a3 and a3test using the command make all or
simply make. The Makefile is provided for you. Your submission should consist of a single zip file with a suitable
name (e.g., assignment2.zip) that contains a folder containing all your files. This folder should also contain a
README with your name, student number, a list of all files that are included, a directory structure (if applicable),
compiling and running instructions, and any other information that will make the TAs life easier when they mark
your assignment.
Below are the changes you should make to the existing project. Section 6.1 should be applied to all classes.
6.1 Encapsulation
You should apply the const keyword to existing classes wherever possible. That means any function that can be made
const should be, and any parameter that can be made const should be. The only exceptions are (Test)Control,
Tester, and View classes - you do not need to apply const to these classes.
VERY IMPORTANT!!! YOU WILL LOSE MARKS IF YOU DO NOT CONST YOUR FUNC TIONS AND PARAMETERS!!!.
6.2 The File Class
We are going to modify the lessThan function, and add an equals function.
1. Adjust the lessThan() function so that it returns true if this File’s name comes before the parameter’s name
in alphabetical order. If the two names are equal (i.e., it is the same File) then order them as defined by
Date::lessThan using the lastModified parameter.
2. Make an equals() function that returns true if the name and the Date are equal (you do not have to compare
the content).
6.3 The Repo Class
You should add a copy constructor to the Repo class that does a deep copy of all data. Be sure to add any other
functions that you require, here or in other classes, to correctly manage your memory.
6.4 The List Classes
Modify FileList and RepoList so that they are both implemented using DOUBLY LINKED LISTS. You should
keep the same interface (public functions defined in the header), and the functions should do the same jobs as before
(except for isFull, detailed below).
Observe that once you change the implementation, everything should work exactly as before. That means all
the tests will pass whether you change these classes or not. But a TA will check and deduct or award marks as
appropriate. There is an additional change detail below.
1. FileList and RepoList:
(a) Have isFull() always return false.
COMP2404 -“Introduction to Software Engineering”
Assignment 3
(b) As a reminder, FileList should add Files in the order defined by File::lessThan, while RepoList
should add Repos to the back of the list.
6.5 The Client Class
Make a Client class. Refer to the UML diagram for function specifications. As in the GetHub class, when an
operation fails, be sure to send an appropriate error message to cout.