CMPT 225 Lab 3: The pain of non-object-oriented design

CMPT 225 Lab 3: The pain of non-object-oriented design


In this lab we will implement a very small part of a big problem without object oriented design. Hopefully, by the end of the lab you will see why we sometimes wrap some variables together and define a class/struct, and also, appreciate how classes could make the programmers' life easier.

Problem

As part of a grad school application, one should list their publications. For each publication, the applicant must provide

Without using classes or structs, you will be completing a piece of code that keeps a list of publications and allows the following commands:

  1. add a publication
  2. remove a publication
  3. sort the publications based on the year of publication
  4. print the list of publications (one per line and print an empty line after)

The input is given in a file like commands.txt :

save_application	"authors_list1"	"title1"	"conference1"	2016	"poster"
save_application	"authors_list3"	"title3"	"conference2"	2010	"oral"
save_application	"authors_list2"	"title2"	"journal1"	2015	"none"
print
sort
print
remove_application	1
print

The output for this file should be

"authors_list1"	"title1"	"conference1"	2016	"poster"
"authors_list3"	"title3"	"conference2"	2010	"oral"
"authors_list2"	"title2"	"journal1"	2015	"none"

"authors_list3"	"title3"	"conference2"	2010	"oral"
"authors_list2"	"title2"	"journal1"	2015	"none"
"authors_list1"	"title1"	"conference1"	2016	"poster"

"authors_list3"	"title3"	"conference2"	2010	"oral"
"authors_list1"	"title1"	"conference1"	2016	"poster"

Lab Activities

  1. Download publication_management_no_class.cpp and complete it by filling in the save_application, remove_application, move, and print functions. You should declare your own global variables to keep the data. Remember you are not allowed to define a class or struct; you can only use arrays, vectors (preferred) , etc.

    Upload the completed publication_management_no_class.cpp to lab3 activity in CMPT 225 on CourSys.

    You can test your implementation by compiling and running the program on the given commands.txt and verify you get the output specified.

    If you decided to use vectors, please note that the following functionality is available:

    vector v;
    v.push_back("hello!");   // will insert hello at the end of the vector
    v.erase(v.begin()+i); // will erase the item at position i in the vector
    sort(v.begin(), v.end()); // will sort the vector. you have to include <algorithm> for this though
    
  2. Answer the following questions:
    • Were you able to use the sort function provided for vectors?
    • Wouldn't it be easier if you were allowed to define classes?
    • What if you were to implement a system for managing the whole application system explained below?

The Whole Application Process

  1. Application is completed

    An applicant should fill in an application form and provide details of their best courses as well as referees' contact information for future references.If they are applying for grad school, they should also provide a list of their publications.

    Here you can see the information that they will provide in each part of their application:

    in application form:

    • string name
    • string address
    • string phone
    • string email
    • string birthday

    for each course in the selected courses:

    • string course names
    • int the grade
    • string the corresponding semester
    • string notes on them (could be empty)

    for each referee in the list of referees:

    • string name
    • string email

    for each application in the list of publications:

    • string list of authors including the student name (order matters)
    • string title
    • string name of conference or Journal
    • int publication year
    • string presentation type (poster, oral, no presentation)
  2. References are collected

    After the application is submitted, the referees are contacted and will provide the following information:

    • text reference
    • answer to 5 predefined multichoice questions (answers are positive integers)
  3. Decisions are made

    After the application deadline is passed and are applications are complete and references are collected, each application will be reviewed by 3 professors who will each give a score between 0 and 10 to the application.

    Undergraduate applicants will be sorted based on the average of reviewers' scores and 100 of them will be admitted.

    Graduate applicants will be admitted if and only if at least one of the reviewers have given them a score of 9 or more.