TCES 203 Assignment 6 – Inheritance

$30.00

Category:

Description

5/5 - (2 votes)

This assignment tests your understanding of concepts covered in the course dealing with
inheritance. For this assignment, you have to create four classes with the corresponding
header and implementation files as well as a test file that contains the main function.
Write separate functions in main file to test each individual class.
You will create a doubly linked list that contains a head and tail node as member
variables. You will create two derived classes called Stack and Queue that use the doubly
linked list as a base class. Test each class thoroughly before moving on to the next class.
Don’t forget to check for memory leaks.
A Node class that allows user to store a name and stores a reference to the previous
and the next node. Provide a constructor, overloaded constructor and setters/getters
for the member variables. Make your member variables private. Validate the parameter
name to make sure that it is not NULL or less than 3 characters long. If it is, display a
message and return from the function. You may use a string object to store the name.
A List class that represents a doubly linked list with a reference to the front and the back
node of the list. Provide a default and overloaded constructor that takes name as the
parameter. Provide addFirst, addLast, removeFirst and removeLast functions to allow
for addition and removal of nodes. Provide a size function that returns the size of the list
as well as an isEmpty function that returns true or false. Overload << operator to print
the contents of the list. Provide a destructor.
A Stack class that inherits from the List class. Provide push, pop functions that follow the
stack policy. Overload << operator to print the contents of the stack. The function pop
should output that the stack is empty if you call the function on an empty stack.
A Queue class that inherits from the List class. Provide enqueue, dequeue functions that
follow the queue policy. Overload << operator to print the contents of the queue. The
function dequeue should output that the queue is empty if you call the function on an
empty queue.
Overloading << operator with inheritance will pose a problem since it is a friend
function. A way to get around this problem is to provide a virtual member function that
will print the corresponding class members (to ostream) in the base class and the
corresponding derived classes. This member function can then be called from the
operator function.
Submission and Grading:
Node.h, Node.cpp, List.h, List.cpp, Stack.h, Stack.cpp, Queue.h, Queue.cpp and
main.cpp files must be on Subversion as we did in the lab under the Project name,
Inheritance. You still have only till midnight to do this. Please do not commit past
midnight.
There will be points taken off for not following the conventions listed in this document
regarding submissions, outputs and naming conventions.
You are required to properly indent your code and will lose points if you make significant
indentation mistakes. See the textbook for an explanation and examples of proper
indentation.
Give meaningful names to functions and variables in your code. Localize variables
whenever possible — that is, declare them in the smallest scope in which they are needed.
Include a comment at the beginning of your program with basic information and a
description of the program and include a comment at the start of each function. Your
comments should be written in your own words and not taken directly from this
document. Write comments within functions to explain the flow or any obscure code.
Provide comments for the functions as well as for the class definition. Make sure that
every file has a header comment including the .h and the main.cpp files.
You should include a comment at the beginning of your program with some basic
information and a description of the program, as in:
// Menaka Abraham
// 3/30/15
// 203
// Assignment #1
//
// This program will…