1. Homepage
  2. Programming
  3. COMP2011 Programming with C++ - PA3: Course Management System

COMP2011 Programming with C++ - PA3: Course Management System

Engage in a Conversation
Hong KongHKUSTCOMP2011Programming with C++Course Management SystemC++

COMP2011 PA3: Course Management System CourseNana.COM

Announcements

This section will be updated after the release. Important announcements will also be sent to students via Canvas. CourseNana.COM

 

Introduction

Your goal is to implement a course management system using linked lists. CourseNana.COM

The system maintains 2-dimensional sorted linked lists: CourseNana.COM

  • The main course list is a sorted Course linked list, sorted by code
  • For each course, there are 2 sorted CourseItem linked lists, sorted by course->code

Here is an example to illustrate the system. In this example, CourseNana.COM

  • 3 courses (COMP1021, COMP1022P, and COMP2011) are added
  • Several pre-requisites and exclusions are added

You can see a sample list display on the left.
The equivalent linked list illustration is shown on the right, surrounded by a dashed box.
To simplify the display, attributes such as title and credit are not shown on the linked list illustration.
CourseNana.COM

Design

The high-level design is shown on the left.
The C++ struct definitions are shown on the right.
CourseNana.COM

The course code is the unique key (i.e., there won't be duplicated course codes in the system).
In this figure, only the main list and one exclusions sub-list are shown.
CourseNana.COM

Tasks

The system supports the following 11 tasks: CourseNana.COM

Assumptions

  • The course code is at least 2 characters (including NULL) and at most 10 characters (including NULL). You don't need to check if the input is invalid.
  • The course title is at least 2 characters (including NULL) and at most 100 characters (including NULL). You don't need to check if the input is invalid.
  • The course credit is a non-negative integer. The checking is already done in the skeleton code.

Think carefully before writing code

In this project assignment, you are free to define new constants, variables (excluding global variables), functions, etc. CourseNana.COM

The suggested order of implementation is: Insertions > Modifications > Deletions CourseNana.COM

For each task on this web page, we illustrate the general cases using some sample data CourseNana.COM

For each task, think carefully about the special cases. For example: CourseNana.COM

  • What should you do if a linked list is empty?
  • What should you do if there is an existing course code/pre-requisite/exclusion when you are doing insertions?
  • What should you do if one/both of the course codes does not exist when you are doing insertions of pre-requisite and exclusion?
  • What should you do if the course code/pre-requisite/exclusion does not exist when you are doing modifications/deletions?
  • What situations you need to consider when you need to change the head pointer (e.g., deleting the first item, inserting as the new first item, etc.)?
  • ... and so on

Think carefully about the code design. For example: CourseNana.COM

  • Pre-requisites and exclusions are similar.
    Can you write some helper functions to handle the common parts, and reuse them in the handling of pre-requisites and exclusions?
    Although the code design is not one of the grading criteria, a good design will make your code more readable and easier to debug and maintain.

For deletions, you should avoid problems such as dangling pointer and memory leak CourseNana.COM

Task 1: Display the current list

Given Do not modify
void ll_print_all(const Course* head); // given, you cannot make any changes

The display of the current list is given. Do not modify any lines of the given code of the display list function. The display consists of 4 sections: CourseNana.COM

  1. Display the main course list
  2. Display the course titles
  3. Display the pre-requisites
  4. Display the exclusions

Here is a sample list when the system is empty: CourseNana.COM

Here is a sample list when there are some courses, pre-requisites, and exclusions: CourseNana.COM

Task 2: Insert a new course

To simplify the display, attributes such as title and credit are not shown
bool ll_insert_course(Course* &head, const char c[MAX_CODE], const char t[MAX_TITLE], int cred);

The main course list is sorted by code. For each insertion, you need to find the correct position to insert. CourseNana.COM

Here is an example, starting from an empty linked list: CourseNana.COM

Step 1: Start from an empty linked list

Shape

Description automatically generated

Step 2: Insert COMP1021

  CourseNana.COM

Task 3: Insert a Prerequisite

To simplify the display, attributes such as title and credit are not shown
bool ll_insert_prerequisite(Course* head, const char targetCode[MAX_CODE], const char preCode[MAX_CODE]);

For each insertion, you need to find the correct position to insert. CourseNana.COM

The self-prerequisite (i.e., pointing to itself) is already handled in the skeleton code. You don't need to handle this special case. CourseNana.COM

You don't need to handle logical errors, such as circular pre-requisites (e.g., A requires B, B requires C, C requires A) CourseNana.COM

Here is an example, starting from the main course list without any prerequisites. CourseNana.COM

Step 1: A starting point

Step 2: Insert a Prerequisite (COMP2011 requires COMP1021)

Step 3: Insert a Prerequisite (COMP2011 requires COMP1022P)

  CourseNana.COM

Task 4: Insert an Exclusion

To simplify the display, attributes such as title and credit are not shown
 
bool ll_insert_exclusion(Course* head, const char targetCode[MAX_CODE], const char excludeCode[MAX_CODE]);

The task is very similar to inserting pre-requisites. CourseNana.COM

The self-exclusion (i.e., pointing to itself) is already handled in the skeleton code. You don't need to handle this special case. CourseNana.COM

You don't need to handle logical errors, such as circular exclusions (e.g., A excludes B, B excludes C, C excludes A) CourseNana.COM

Here is an example, starting from a main course list without any exclusions. CourseNana.COM

Step 1: A starting point (from the previous task)

  CourseNana.COM

Step 2: Insert an Exclusion (COMP1021 excludes COMP1022P)

Step 3: Insert an Exclusion (COMP1022P excludes COMP1021)

CourseNana.COM

Task 5-6: Delete an existing prerequisite/exclusion

To simplify the display, unrelated attributes and links are hidden
bool ll_delete_prerequisite(Course* head, const char targetCode[MAX_CODE], const char preCode[MAX_CODE]);
 
bool ll_delete_exclusion(Course* head, const char targetCode[MAX_CODE], const char excludeCode[MAX_CODE]);

Deleting an existing pre-requisite and deleting an existing exclusion are very similar.
In this example, only the deletion of an existing pre-requisite is shown:
CourseNana.COM

Step 1: Before deleting a prerequisite COMP1021 from COMP2011

  CourseNana.COM

Step 2: After deleting a prerequisite COMP1021 from COMP2011

  CourseNana.COM

Task 7: Delete an existing course

To simplify the display, unrelated attributes and links are hidden
bool ll_delete_course(Course* &head, const char c[MAX_CODE]);

Deleting an existing course is not trivial. You need to handle problems such as dangling pointer and memory leak CourseNana.COM

Here is an example to delete a course (COMP1022P) from the system: CourseNana.COM

Step 1: Explanation about the dangling pointer problem

  CourseNana.COM

Step 2: A starting point before deletion of COMP1022P

  CourseNana.COM

Step 3: Deleting all links that are pointed to COMP1022P

  CourseNana.COM

  CourseNana.COM

Step 4: Deleting all prerequisites and exclusions to avoid memory leak

  CourseNana.COM

Step 5: Deleting the COMP1022P node from the main list

  CourseNana.COM

  CourseNana.COM

ask 8-9: Modify a course title/credit

To simplify the display, unrelated attributes and links are hidden
bool ll_modify_course_title(Course* head, const char c[MAX_CODE], const char t[MAX_TITLE]);
 
bool ll_modify_course_credit(Course* head, const char c[MAX_CODE], int cred);

Modifying the course title/credit if the target node is found.
Suppose COMP2011 is the target, here is an example to modify its course title and credit:
CourseNana.COM

  CourseNana.COM

If the new course title/credit is the same as the old course title/credit, it is still regarded as a successful modification. CourseNana.COM

In this assignment, you do not need to modify the course code. It is because all the linked lists in the system are sorted by course code, it is very tricky to modify a course code. We cannot simply delete a course and then add the course back because all the course links of pre-requisites and exclusions will be lost. CourseNana.COM

Task 10-11: Exit with/without clean-up

void ll_cleanup_all(Course* &head);

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Hong Kong代写,HKUST代写,COMP2011代写,Programming with C++代写,Course Management System代写,C++代写,Hong Kong代编,HKUST代编,COMP2011代编,Programming with C++代编,Course Management System代编,C++代编,Hong Kong代考,HKUST代考,COMP2011代考,Programming with C++代考,Course Management System代考,C++代考,Hong Konghelp,HKUSThelp,COMP2011help,Programming with C++help,Course Management Systemhelp,C++help,Hong Kong作业代写,HKUST作业代写,COMP2011作业代写,Programming with C++作业代写,Course Management System作业代写,C++作业代写,Hong Kong编程代写,HKUST编程代写,COMP2011编程代写,Programming with C++编程代写,Course Management System编程代写,C++编程代写,Hong Kongprogramming help,HKUSTprogramming help,COMP2011programming help,Programming with C++programming help,Course Management Systemprogramming help,C++programming help,Hong Kongassignment help,HKUSTassignment help,COMP2011assignment help,Programming with C++assignment help,Course Management Systemassignment help,C++assignment help,Hong Kongsolution,HKUSTsolution,COMP2011solution,Programming with C++solution,Course Management Systemsolution,C++solution,