CS240 - Introduction to Computing III mp03 (templates) 

Project setup

Create the project mp03.<FirstLast. Replace FirstLast with your name and do not include the < brackets. For instance, mp03.SocratisTornaritis.

Add the provided files to your project:


Name.hpp, Name.cpp

ArrayList.hpp, ArrayList.cpp

The folder mp03.Firstlast containing just the source file(s) and text file(s), is the one that you must zip and upload. Do not upload any IDE specific files.

Refer to the appropriate "how to" tutorial notes available on the course website, for instructions on how to create a project and manage its files.

Problem description:

This mp has two parts to it. The first is to rewrite the ArrayList example we did in class and change the array elements to Name elements, rather than Name * elements. The second is to convert the ArrayList class to a template and implement the <<() function as a template.

Original list: [

John Smith

Tobby Appleseed

Mary Appleseed


First name: John Smith

Is John Smith before Tobby Appleseed alphabetically? No

Copy list: [

Mary Poppins

Tobby Appleseed

Mary Appleseed


Original list: [

John Smith

Tobby Appleseed

Mary Appleseed

1 / 2 Last updated: September 28, 2016 at 7:05 AM

Program requirements:

(1) Complete the implementation of the Name class. 

Implement the relational operator methods and <<() function. Refer to class examples.

(2) Update the interface file for the ArrayList class.

Update the ArrayList's declaration to reflect the new element type, which this time is a Name object, rather than a Name *.

(3) Implement the class inline.

An inline implementation means that the class declaration is now also the class definition. Copy the relevant code from the implementation file into the interface file. When finished, it will look very much like a Java class implementation, all in one basically. Refer to class example for details.

(4) Remove the ArrayList implementation file from the project.

Since we are using inline methods, remove the .cpp file from the project, else you will run into compilation errors.

(5) Now make the ArrayList class into a template. 
Turn the ArrayList into a template.

As you write your programs from here on out, documentation will be desirable and an essential part of your code. Add the following section to each of your programs to identify relevant information to anyone reading your code. The sample below is what I used for Main.java, so make the appropriate changes to reflect your current/accurate information. This is just a sample, so feel free to add to it if you want, but do not remove anything.

/* File: <filename

* Name: <your name

* Revised: <date authored

* Course: CS240 - Introduction to Computing III


* Desc: <program description


Grading Rubric

Wrong files submitted, or late submission
Program does not compile or run
Coding style

- no comments, bad variable names, no code structure
Name class
ArrayList class
: inline
: 20
: template
: 15
2 / 2 Last updated: September 28, 2016 at 7:05 AM
Powered by