CMPT 225 Lab 1: Your favorite data type

CMPT 225 Lab 1: Your favorite data type


In this lab we will write a class that can be used as a data type in SortedArrayList.

This data type is a class similar to patient class that we developed in Lecture 4. But it can have any set of member data. For example, if you are like me, your favorite data type is something like movie rather than patient. A movie has a name, a year of production, a length, a rating, etc. I can define all these features as member variables of myFavoriteDataType. Then the constructor of my class would take values for these members. The problem is, this class can't be used in SortedArrayList just like patient class wasn't at first. So, I need to add all the functions and operators that are needed (just like what we did in lecture 4) for my class to be consumable by SortedList. That is what we are doing in this lab.

What to submit?

  1. The header and implementation file for the class (myFavoriteDataType.h and myFavoriteDataType.cpp)
  2. A constructor_params.txt file containing exactly 5 set of parameters for the constructor of the class, each at a line. parameters in a line are seperated from each other with commas. In fact each line in constructor_params.txt should be exactly the same as what you'd put in parantheses when calling the constructor of your data type. The following is an example of constructor_params.txt for a class whose constructor takes a string and a number:
    "P17", 17
    "P5", 5
    "P3", 3
    "P100", 100
    "P24", 24
    
    If myFavoriteDataType is movie, I have name (a string), year of production (an int), length (an int), and rating (a float) as constructor parameters. Then, constructor_params.txt could contain something like the following.
    "movie1", 2000, 120, 3.5
    "movie2", 2005, 95, 4.9
    "movie3", 2002, 80, 2.5
    "movie4", 2017, 100, 4.0
    "movie5", 1995, 170, 4.8
    

Where to submit?

In CourSys under CMPT 225 Lab1 activity.

How to test?

  1. Download this folder and copy the files you will be submitting into it.
  2. Compile your class to get a myFavoriteDataType.o.
  3. Compile testFileGenerator.cpp to get testFileGenerator.o.
  4. Run testFileGenerator.o (it takes no parameters) to get a generated_tester.cpp.
  5. Compile generated_tester.cpp to get a generated_tester.o. Remember that it depends on myFavoriteDataType.o.
  6. Run generated_tester.o (it takes no parameters). It should print the 5 objects whose parameters you provided in the right order.

Some hints