version: 1.7 last updated: 2025-11-20 22:00

Assignment 2 - CS Festival

Overview

Welcome to CS Festival

With the rising popularity of large-scale music festivals and packed multi-stage lineups, organisers need smart tools to manage stages, performances, and setlists seamlessly. Your task is to implement CS Festival, a comprehensive festival planning system

This assignment will test your ability to create, use, manipulate, and solve problems using linked lists. You will represent songs, performances, and stages using linked lists within a central festival structure.

COMP1911 Students

If you are a COMP1911 student, you will be assessed on your performance in up to and including Stage 3.3 ONLY for this assignment, which will make up the performance component of your grade. Style will be marked as usual and will make up the remaining 20% of the marks for this assignment. You are not required to attempt Stages 3.4 and beyond. You may attempt the later stages if you wish, but you will not be awarded any marks for work beyond Stage 3.3.

COMP1511 Students

If you are a COMP1511 student, you will be assessed on your performance in Stages 1, 2, 3, and 4, which will make up the performance component of your grade. Style will be marked as usual and will make up the remaining 20% of the marks for this assignment.

Getting Started

There are a few steps to getting started with CS Festival.

  1. Create a new folder for your assignment work and move into it.
 mkdir ass2
 cd ass2
 
  1. Use this command on your CSE account to copy the file into your current directory:
1511 fetch-activity cs_festival
  1. Run 1511 autotest cs_festival to make sure you have correctly downloaded the file.
1511 autotest cs_festival
  1. Read through this introduction and Stage 1.

  2. Spend a few minutes playing with the reference solution.

 1511 cs_festival
  1. Think about your solution, draw some diagrams to help you get started.

  2. Start coding!

Assignment Structure & Starter Code

This assignment utilises a multi-file system. There are three files we use in CS Festival:

  • Main File (main.c): This file contains the main function, which serves as an entry point for the program. It is responsible for printing a welcome banner, setting the festival's name, creating the festival, and initiating a command loop so users can interact with the app.

A main() function has been provided in main.c to get you started.

int main(void) {
    // Welcome banner
    print_welcome_banner();

    // Festival plan setup
    printf("Enter the name of your festival: ");
    char festival_name[MAX_SIZE];
    scan_name(festival_name);
    struct festival *my_festival = create_festival(festival_name);

    // Command loop
    command_loop(my_festival);

    // End message
    printf("Goodbye!\n");
    
    return 0;
}

Printing a Welcome Banner

The first statement in main() calls the provided print_welcome_banner() function to print a welcome banner:

void print_welcome_banner() {
    printf("Welcome to CS Festival!\n");
    printf("♪┏(・o・)┛┗ ( ・o・) ┓♪\n");
}

Scanning the Festival Name

In this section, the program receives input from the user for the festival's name.

It declares festival_name, a character array of size MAX_SIZE to store the festival's name.

It then uses the provided scan_name() function, which reads user input and stores it in the festival_name array.

printf("Enter the name of your festival: ");
char festival_name[MAX_SIZE];
scan_name(festival_name);

Creating the Festival

Next, the program creates the festival itself. It:

  • Declares a pointer my_festival to a struct festival.
  • Calls create_festival(), passing festival_name as an argument.
  • Stores the pointer returned by create_festival() in my_festival.

struct festival *my_festival = create_festival(festival_name);

The create_festival() function is currently incomplete. You will need to implement this in Stage 1.1. It is responsible for setting up the initial state of the festival, including allocating memory and setting default values.

Starting the Command Loop

After creating the festival, the program starts a command loop by calling the command_loop() function which you will need to implement in Stage 1.2. This function allows users to interact with the app to add or remove stages, performances, songs, and more.

command_loop(my_festival);

Exiting the Program

The last statement in main() prints a goodbye message:

printf("Goodbye!\n");

  • Header File (cs_festival.h): This file declares constants, enums, structs, and function prototypes for the program. You will need to add prototypes for any functions you create in this file. You should also add any of your own constants and/or enums to this file.

  • Implementation File (cs_festival.c): This file is where most of the assignment work will be done, as you will implement the logic and functionality required by the assignment here. This file also contains stubs of Stage 1 functions for you to implement. It does not contain a main function, so you will need to compile it alongside main.c. You will need to define any additional functions you may need for later stages in this file.

The implementation file cs_festival.c contains some "Provided Function Definitions" to help simplify some stages of this assignment. These functions have been implemented and should not need to be modified to complete this assignment.

These provided functions will be explained in the relevant stages of this assignment. Please read the function comments and the specification as we will suggest certain provided functions for you to use.

We have defined some structs in cs_festival.h to get you started. You may add fields to any of the structs if you wish.

The Festival

struct festival {
    // The name of your festival
    char name[MAX_SIZE];
    // The list of stages in the festival
    struct stage *stages;
};

Purpose: To store all the information about the festival. It contains:

  • The festival’s name.
  • A list of stages, each with their own performances.

Stages

struct stage {
    // The name of the stage
    char name[MAX_SIZE]; 
    // The list of performances on the stage
    struct performance *performances;
    // The next stage in the festival
    struct stage *next;
};

Purpose: To represent a stage at the festival. It contains:

  • The stage’s name.
  • A list of performances scheduled on this stage.
  • A pointer to the next stage in the festival.

Performances

struct performance {
    // The name of the band performing
    char band_name[MAX_SIZE];
    // The start time of the performance 
    // (in minutes from the start of the festival)
    int start_time; 
    // The end time of the performance 
    // (in minutes from the start of the festival)
    int end_time;
    // The maximum duration allowed for the performance (in minutes)
    int max_duration; 
    // The genre of the performance
    enum genre genre; 
    // The setlist of songs for the performance
    struct song *setlist;
    // The next performance in the list
    struct performance *next;
};

Purpose: To represent a band’s performance on a stage. It contains:

  • The band’s name.
  • The performance’s start and end time (minutes from the start of the festival).
  • The maximum allowed duration (minutes).
  • The music genre (e.g., Rock, Pop, Country, Jazz, Metal, Hip Hop).
  • A setlist of songs to be performed.
  • A pointer to the next performance on the stage.

Songs

struct song {
    // The title of the song
    char title[MAX_SIZE];
    // The duration of the song (in minutes)
    double duration; 
    // The popularity rating of the song (1-10)
    int popularity; 
    // The next song in the setlist
    struct song *next;
};

Purpose: To represent a song in a performance setlist (list of songs to be performed). It contains:

  • The song’s title.
  • Its duration (minutes).
  • Its popularity rating (out of 10).
  • A pointer to the next song in the setlist.

The following enum definition is provided for you in cs_festival.h. You can create your own enums if you would like, but you should not need to modify the provided enum.

Order Status

enum genre {
    ROCK,
    POP,
    COUNTRY,
    JAZZ,
    METAL,
    HIPHOP,
    INVALID_GENRE
};
Purpose: To represent the genre of a performance


Reference Implementation

To help you understand the expected behaviour of CS Festival, we have provided a reference implementation. If you have any questions about the behaviour of your assignment, you can compare its output to the reference implementation.

To run the reference implementation, use the following command:

 1511 cs_festival

Input:

CS_FESTIVAL
?
q

Input and Output:

1511 cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: CS_FESTIVAL
Enter command: ?
*********************[     Usage Info     ]********************* 
  a s [name]                                                     
    Add a stage with unique name                                 
  a p [stage_name] [band_name] [genre] [max_duration]            
    Append a performance to a stage                              
  i g [stage_name] [band_name] [title] [duration] [popularity] [position]
    Insert a song at [position] in a performance                 
  p                                                              
    Print the festival with all stages and performances          
  *                                                              
    Print the most popular performance(s)                        
  P [band_name]                                                  
    Print schedule and setlists for [band_name], plus summary    
  x s [stage_name]                                               
    Close a stage and free all its performances                  
  x p [stage_name] [band_name]                                   
    Remove a performance from a stage                            
  x g [stage_name] [band_name] [position]                        
    Remove the nth song from a performance                       
  u [stage_name] [band_name] [new_duration]                      
    Update performance max duration, trimming songs if shorter   
  m [src_stage] [dest_stage] [band_name] [position]              
    Move a performance to [dest_stage] at [position]             
  j [stage_name1] [band_name1] [stage_name2] [band_name2]        
    Join two performances                                        
  c v [band_name]                                                
    View all conflicting performances for [band_name]            
  c r [band_name]                                                
    Resolve all conflicting performances for [band_name]         
  ?                                                              
    Show this help information                                   
  q                                                              
    Quit the program                                             
****************************************************************
Enter command: q
Goodbye!

Allowed C Features

This assignment must be implemented exclusively using linked lists for all core data structures and logic.

Other than arrays, there are no restrictions on C features in this assignment, except for those outlined in the Style Guide. If you choose to use features beyond what has been taught in COMP1511/1911, be aware that course staff may not be able to assist you.

FAQ

Q: Can I edit the provided code?

Yes! Feel free to modify, replace, or discard any of the provided code.

For example: you may wish to add fields to the provided struct festival definition.

You are also encouraged to create your own constants, enums, structs, and helper functions.

Q: What C features can I use?

For everything not taught in the course, check the Style Guide:

  • If the guide says "avoid", it may incur a style mark penalty if not used correctly.
  • If the guide says "illegal" or "do not use", it will result in a style mark penalty (see the Style Marking Rubric).

These rules exist to ensure that everyone develops the required foundational knowledge and to maintain a level playing field for all students.

Q: Can I use arrays?

A: No, you cannot use arrays in any part of this assignment. The only exception is when using strings. Using arrays for any part of this assignment will result in a performance mark of zero.

Stages

The assignment has been divided into incremental stages.

Stage 1

  • Stage 1.1 - Creating and Initialising Structs.
  • Stage 1.2 - Command Loop.
  • Stage 1.3 - Add Stage.
  • Stage 1.4 - Printing the Festival.

Stage 2

  • Stage 2.1 - Append Performance.
  • Stage 2.2 - Insert Song.
  • Stage 2.3 - Print Most Popular Performance.
  • Stage 2.4 - Print Band Summary.

Stage 3

  • Stage 3.1 - Cancel Festival Plan.
  • Stage 3.2 - Remove Stage and Performance.
  • Stage 3.3 - Remove Song.
  • Stage 3.4 - Update Performance Duration.
  • Stage 3.5 - Move Performance.

Stage 4

  • Stage 4.1 - Join Performances.
  • Stage 4.2 - Scheduling Conflicts.

Extension (not for marks)

  • SplashKit - Create and Share a Graphical User Interface.

Video Overview

A video explanation to help you get started with the assignment can here found here:

Your Tasks

This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order.

Stage 1

Stage 1 is where you turn your starter code into the foundation of a festival planner.

This milestone has been divided into four substages:

  • Stage 1.1 - Creating and Initialising Structs.
  • Stage 1.2 - Command Loop.
  • Stage 1.3 - Add Stage.
  • Stage 1.4 - Printing the Festival.

Stage 1.1 - Create and Initialise Structs

In this stage, you shape the core data structures for building the CS Festival plan.

Your first task is to implement the following four functions:

  1. create_festival()
  2. create_stage()
  3. create_performance()
  4. create_song()

Each of these functions takes in a list of parameters detailed in cs_festival.h, and returns a pointer to a struct.

You will find unimplemented function stubs for these functions in cs_festival.c.

// Stage 1.1
// Function to create and initialise a festival
// Params:
//      name - the name of the festival
// Returns: 
//      A pointer to the newly created festival
struct festival *create_festival(char name[MAX_SIZE]) {
    // TODO: implement this function
    printf("create_festival() not yet implemented\n");
    return NULL;
}
// Function to create and initialise a stage
// Params:
//      name - the name of the stage
// Returns: 
//      A pointer to the newly created stage
struct stage *create_stage(char name[MAX_SIZE]) {
    // TODO: implement this function
    printf("create_stage() not yet implemented\n");
    return NULL;
}
// Function to create and initialise a performance
// Params:
//      band_name   - the name of the band
//      start_time  - the start time of the performance 
//                    (in minutes from the start of the festival)
//      max_duration- the maximum duration allowed for the performance 
//                    (in minutes)
//      genre       - the genre of the performance 
// Returns: 
//      A pointer to the newly created performance
struct performance *create_performance(
    char band_name[MAX_SIZE], 
    int start_time, 
    int max_duration, 
    enum genre genre
) {
    // TODO: implement this function
    printf("create_performance() not yet implemented\n");
    return NULL;
}
// Function to create and initialise a song
// Params:
//      title      - the title of the song
//      duration   - the duration of the song (in minutes)
//      popularity - the popularity rating of the song 
// Returns: 
//      A pointer to the newly created song
struct song *create_song(
    char title[MAX_SIZE],
    double duration, 
    int popularity
) {
    // TODO: implement this function
    printf("create_song() not yet implemented\n");
    return NULL;
}

To implement these functions:

  1. Find the function stubs in cs_festival.c and read the provided comments.
  2. Malloc the space required for the struct.
  3. Assign the provided parameters to the struct's fields.
  4. Initialise all remaining struct fields to some reasonable values.
  5. Return a pointer to the newly-created struct.

Clarifications

  • No error handling is required for this stage.
  • The start time and end time of a performance are integers representing the number of minutes from the start of the festival (at minute 0).
  • A performance's end time is the performance's start time + max duration.

Testing

There are no autotests for Stage 1.1.

You will need to test your work by:

  1. Compiling your code with dcc to ensure there are no warnings or errors.
  2. Writing temporary testing code to confirm that your functions behave as expected.

You can copy the following testing code into your main() function in main.c.

#include <stdio.h>

#include "cs_festival.h"

int main(void) {
    // create festival 
    char festival_name[MAX_SIZE] = "CS_Festival";
    struct festival *festival = create_festival(festival_name);

    // Check if create_festival() has returned NULL
    if (festival == NULL) {
        printf("ERROR: create_festival() has returned NULL\n");
    }

    // Print festival details
    printf("Festival created:\n");
    printf("  Name: %s\n", festival->name);
    if (festival->stages == NULL) {
        printf("  Stages: NULL\n\n");
    } else {
        printf("  Stages: (not NULL)\n\n");
    }

    // Create stage
    char stage_name[MAX_SIZE] = "UNSW";
    struct stage *stage = create_stage(stage_name);

    // Check if create_stage() has returned NULL
    if (stage == NULL) {
        printf("ERROR: create_stage() has returned NULL\n");
    }

    // Print stage details
    printf("Stage created:\n");
    printf("  Name: %s\n", stage->name);
    if (stage->performances == NULL) {
        printf("  Performances: NULL\n");
    } else {
        printf("  Performances: (not NULL)\n");
    }
    if (stage->next == NULL) {
        printf("  Next Stage: NULL\n\n");
    } else {
        printf("  Next Stage: (not NULL)\n\n");
    }

    // Create performance
    char band_name[MAX_SIZE] = "The_Beatles";
    struct performance *performance = create_performance(band_name, 0, 90, ROCK);

    // Check if create_performance() has returned NULL
    if (performance == NULL) {
        printf("ERROR: create_performance() has returned NULL\n");
    }

    // Print performance details
    printf("Performance created:\n");
    printf("  Band Name: %s\n", performance->band_name);
    printf("  Start Time: %d\n", performance->start_time);
    printf("  End Time: %d\n", performance->end_time);
    printf("  Max Duration: %d\n", performance->max_duration);
    char genre_name[MAX_SIZE];
    get_genre_name(performance->genre, genre_name);
    printf("  Genre: %s\n", genre_name);
    if (performance->setlist == NULL) {
        printf("  Setlist: NULL\n");
    } else {
        printf("  Setlist: (not NULL)\n");
    }
    if (performance->next == NULL) {
        printf("  Next Performance: NULL\n\n");
    } else {
        printf("  Next Performance: (not NULL)\n\n");
    }

    // create song
    char song_title[MAX_SIZE] = "Something";
    struct song *song = create_song(song_title, 3.1, 8);
    if (song == NULL) {
        printf("ERROR: create_song() has returned NULL\n");
    }

    printf("Song created:\n");
    printf("  Title: %s\n", song->title);
    printf("  Duration: %.1f\n", song->duration);
    printf("  Popularity: %d\n", song->popularity);
    if (song->next == NULL) {
        printf("  Next Song: NULL\n");
    } else {
        printf("  Next Song: (not NULL)\n");
    }

    return 0;
}

This code calls create_festival(), create_stage(), create_performance() and create_song(), then prints the values stored in the fields of the returned structs.

You can compile and run your program with the following command:

dcc cs_festival.c main.c -o cs_festival
./cs_festival

When you run it, it should print the following:

Festival created:
  Name: CS_Festival
  Stages: NULL

Stage created:
  Name: UNSW
  Performances: NULL
  Next Stage: NULL

Performance created:
  Band Name: The_Beatles
  Start Time: 0
  End Time: 90
  Max Duration: 90
  Genre: ROCK
  Setlist: NULL
  Next Performance: NULL

Song created:
  Title: Something
  Duration: 3.1
  Popularity: 8
  Next Song: NULL

Visually, this can be represented as below:

01_01

Stage 1.2 - Command Loop

In this stage, you teach CS Festival to listen for commands.

Your second task is to begin implementing the command_loop() function. This function is called by the main() function in main.c after creating the festival.

A function stub has been provided in the cs_festival.c starter code.

// Stage 1.2
// Function to run the main command loop for the program
// Params:
//      festival - a pointer to the festival
// Returns: None
void command_loop(struct festival *festival) {
    // TODO: implement this function
    printf("command_loop() not yet implemented\n");
    return;
}

When command_loop() is called, your program should:

  1. Print "Enter command: " to prompt the user to enter a command.
  2. Scan in a command.
  3. Execute the command.
  4. Repeat steps 1 to 3 until the user enters the q quit command.

When q is entered, the function should end and immediately return to the main() function. The program will then print the goodbye message, as included in the starter code in main.c and end.

The command loop will be extended with new commands as you progress through each stage of the assignment.

Command

The first command you will implement is the help command:

?

This command is described below.

Description

When the help command is entered, the program should call the print_help() function provided in the cs_festival.c starter code. This displays a list of information about all commands that will be implemented by the end of this assignment.

// Function to print help information
// '?' command
// Params: None
// Returns: None
// Usage:
// ```
//      print_help();
// ```
void print_help(void) {
    printf(
        "*********************[     Usage Info     ]********************* \n"
        "  a s [name]                                                     \n"
        "    Add a stage with unique name                                 \n"
        "  a p [stage_name] [band_name] [genre] [max_duration]            \n"
        "    Append a performance to a stage                              \n"
        "  i g [stage_name] [band_name] [title] [duration] [popularity] "
        "[position]\n"
        "    Insert a song at [position] in a performance                 \n"
        "  p                                                              \n"
        "    Print the festival with all stages and performances          \n"
        "  *                                                              \n"
        "    Print the most popular performance(s)                        \n"
        "  P [band_name]                                                  \n"
        "    Print schedule and setlists for [band_name], plus summary    \n"
        "  x s [stage_name]                                               \n"
        "    Close a stage and free all its performances                  \n"
        "  x p [stage_name] [band_name]                                   \n"
        "    Remove a performance from a stage                            \n"
        "  x g [stage_name] [band_name] [position]                        \n"
        "    Remove the nth song from a performance                       \n"
        "  u [stage_name] [band_name] [new_duration]                      \n"
        "    Update performance max duration, trimming songs if shorter   \n"
        "  m [src_stage] [dest_stage] [band_name] [position]              \n"
        "    Move a performance to [dest_stage] at [position]             \n"
        "  j [stage_name1] [band_name1] [stage_name2] [band_name2]        \n"
        "    Join two performances                                        \n"
        "  c v [band_name]                                                \n"
        "    View all conflicting performances for [band_name]            \n"
        "  c r [band_name]                                                \n"
        "    Resolve all conflicting performances for [band_name]         \n"
        "  ?                                                              \n"
        "    Show this help information                                   \n"
        "  q                                                              \n"
        "    Quit the program                                             \n"
        "**************************************************************** \n"
    );
}

When the help command finishes, the command loop should repeat steps 1 to 3 to handle user commands until a q quit command has been entered.

Errors

  • If an invalid command or subcommand is entered, your program should print:
    "ERROR: Invalid command.\n".

Examples

Input:

UNSW
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: q
Goodbye!

Input:

UNSW
?
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: ?
*********************[     Usage Info     ]********************* 
  a s [name]                                                     
    Add a stage with unique name                                 
  a p [stage_name] [band_name] [genre] [max_duration]            
    Append a performance to a stage                              
  i g [stage_name] [band_name] [title] [duration] [popularity] [position]
    Insert a song at [position] in a performance                 
  p                                                              
    Print the festival with all stages and performances          
  *                                                              
    Print the most popular performance(s)                        
  P [band_name]                                                  
    Print schedule and setlists for [band_name], plus summary    
  x s [stage_name]                                               
    Close a stage and free all its performances                  
  x p [stage_name] [band_name]                                   
    Remove a performance from a stage                            
  x g [stage_name] [band_name] [position]                        
    Remove the nth song from a performance                       
  u [stage_name] [band_name] [new_duration]                      
    Update performance max duration, trimming songs if shorter   
  m [src_stage] [dest_stage] [band_name] [position]              
    Move a performance to [dest_stage] at [position]             
  j [stage_name1] [band_name1] [stage_name2] [band_name2]        
    Join two performances                                        
  c v [band_name]                                                
    View all conflicting performances for [band_name]            
  c r [band_name]                                                
    Resolve all conflicting performances for [band_name]         
  ?                                                              
    Show this help information                                   
  q                                                              
    Quit the program                                             
****************************************************************
Enter command: q
Goodbye!

Input:

UNSW
z
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: z
ERROR: Invalid command.
Enter command: q
Goodbye!

Clarifications

You may assume that:

  • All commands begin with a single char, followed by additional arguments. The number of arguments will depend on each command.
  • Commands will always be given the correct number of arguments.
  • Commands will always be given arguments of the correct type.

Stage 1.3 - Add Stage

When CS Festival first runs, a new festival with an empty stage list is created as shown below:

01_03_empty_festival

We would like to start planning the schedule, but before this can happen, the festival needs some stages!

In stage 1.3, you will start adding stages to your festival plan!

Command

The add stage command will be called as follows:

a s [stage_name: string]

For example, the command:

a s Forever

would add a stage named Forever to the head of the festival's stage list.

Description

Your task is to complete the add_stage() function stub in cs_festival.c. This function should be called in the command loop to help execute the add stage command.

// Stage 1.3
// Function to add a stage to the festival
// Params:
//      festival - a pointer to the festival
// Returns: None
void add_stage(struct festival *festival) { 
    // TODO: implement this function
    printf("add_stage() not yet implemented\n");
    return;
}

When an add stage command is entered, your program should:

  • Scan the stage name.
  • Create a new stage.
  • Insert the stage at the head of the festival's stage list.
  • Print a message to confirm that the command was successful:
    "Stage '[name]' added.\n"
    where [name] is the name of the new stage.

After adding one stage, the festival plan should look something like this:

01_03_add_one_stage

Any other stages added via this command will be inserted at the head of the list and look something like this:

01_03_add_multiple_stages

Errors

When adding a stage, if a stage with the same name already exists, the stage should not be added, and the following error message should be printed out instead:

"ERROR: Stage with name '[stage_name]' already exists.\n".

Examples

Input:

UNSWUNSW
a s Forever
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSWUNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Forever
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Forever
ERROR: Stage with name 'Forever' already exists.
Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • Stage name comparisons are case-sensitive. For example, "UNSW" and "unsw" are treated as two distinct stages.

Stage 1.4 - Printing the Festival

In this stage, you will implement a function to display the festival plan.

As your program is handling multiple linked lists, this stage is split into two parts to help you in the process:

  1. Printing the setlist.
  2. Printing the entire festival.

Part 1 - Printing the setlist

In this part, you will implement the function print_setlist() to print the list of songs on a performance (also known as a setlist). The songs should be numbered based on each song's position in the list, starting from position 1.

A function stub has been provided in the cs_festival.c starter code. It has a single argument, struct song *setlist, which will be the head of a linked list of struct song.

// Stage 1.4 Part 1
// Function to print the setlist of a performance
// Params:
//      setlist - a pointer to the first song in the setlist
// Returns: None
void print_setlist(struct song *setlist) {
    // TODO: implement this function
    printf("print_setlist() not yet implemented\n");
    return;
}

A helper function, print_song() has also been provided in cs_festival.c to format the song details. You will need to pass in a struct song and the song's position int song_num.

// Function to print a single song for a setlist
// Params: None
// Returns: None
// Usage example:
// ```
//      print_song(song, 1);
// ```
void print_song(struct song *song, int song_num) {
    printf("  %d. %s (%.1f mins, %d)\n",
        song_num,
        song->title,
        song->duration,
        song->popularity
    );
}

If a setlist has no songs, then print_setlist() should print "  (no songs yet)\n" in place of the list of songs.

Testing

As songs won't be added until Stage 2, there are no autotests for Stage 1.4 Part 1.

You will need to test your work by:

  1. Compiling your code with dcc to ensure there are no warnings or errors.
  2. Writing temporary testing code to confirm that your functions behave as expected.

You can copy the following testing code into your main() function in main.c.

#include <stdio.h>
#include <stdlib.h>
#include "cs_festival.h"

int main(void) {
    // Create song title buffers
    char title1[MAX_SIZE] = "Illegal";
    char title2[MAX_SIZE] = "Pain";
    char title3[MAX_SIZE] = "Tonight";
    char title4[MAX_SIZE] = "Take_Me_Home";

    // Create songs using the buffers
    struct song *song1 = create_song(title1, 2.5, 10);
    struct song *song2 = create_song(title2, 1.6, 9);
    struct song *song3 = create_song(title3, 2.9, 6);
    struct song *song4 = create_song(title4, 3.4, 6);

    // Link them into a setlist
    song1->next = song2;
    song2->next = song3;
    song3->next = song4;
    song4->next = NULL;

    // Pass the setlist into print_setlist
    printf("List 1 (four songs)\n");
    print_setlist(song1);

    // Pass an empty setlist into print_setlist
    printf("\nList 2 (no songs)\n");
    print_setlist(NULL);

    return 0;
}

This code calls create_song() to create a list of four songs, just as it might exist inside performance-&gt;setlist. It will then call your implementation of print_setlist() to display that list of songs.

It will also imitate an empty list, by passing NULL into print_setlist(), and it should print "  (no songs yet)\n".

You can compile and run your program with the following command:

dcc cs_festival.c main.c -o cs_festival
./cs_festival

When you run it, it should print each song-list as:

List 1 (four songs)
  1. Illegal (2.5 mins, 10)
  2. Pain (1.6 mins, 9)
  3. Tonight (2.9 mins, 6)
  4. Take_Me_Home (3.4 mins, 6)

List 2 (no songs)
  (no songs yet)

Part 2 - Printing the festival

In Part 2, you will implement the function print_festival() to display the festival plan.

A function stub has been provided in the cs_festival.c starter code.

Command

p

When the print command is entered, your program should print an overview of the entire festival, including the stage list, each stage's performances, and each performance's setlist.

Two functions have been provided for you in cs_festival.c to help format the title of each stage, and the header for a performance.

  • print_stage_title()
  • print_performance_header()

// Function to print a stage title banner
// Params: None
// Returns: None
// Usage example:
// ```
//      print_stage_title(stage);
// ```
void print_stage_title(struct stage *stage) {
    printf("==========================================\n[%s]\n", stage->name);
}

// Function to print a performance header, including its start and end time 
// (formatted as hours:minutes from the start of the festival),
// band name, and genre
// Params: None
// Returns: None
// Usage example:
// ```
//      print_performance_header(performance);
// ```
void print_performance_header(struct performance *performance) {
    char start_buf[6];
    char end_buf[6];
    char genre_buf[11];
    get_genre_name(performance->genre, genre_buf);
    format_time(performance->start_time, start_buf);
    format_time(performance->end_time, end_buf);

    printf("%-5s - %-5s | %s (%s)\n",
        start_buf,
        end_buf,
        performance->band_name,
        genre_buf
    );
}

As for each performance's setlist you can use your function from Part 1!

// Stage 1.4 Part 2
// Function to print the entire festival, including stages and performances
// Params:
//      festival - a pointer to the festival
// Returns: None
void print_festival(struct festival *festival) {
    // TODO: implement this function
    printf("print_festival() not yet implemented\n");
    return;
}

If the festival plan has no stages, then print_festival() should print:
"  (no stages yet)\n" in place of the stage list.

Up to now, the festival plan has no performances, however print_festival() should print:
"  (no performances yet)\n" under the title for empty stages.

Examples

Input:

UNSW
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: p
Festival: UNSW
  (no stages yet)
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: p
Festival: UNSW
==========================================
[Forever]
  (no performances yet)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: p
Festival: UNSW
==========================================
[Live]
  (no performances yet)

==========================================
[Always]
  (no performances yet)

==========================================
[Forever]
  (no performances yet)

Enter command: q
Goodbye!

Clarifications

  • Up to now, stages do not have any performances, so no performances or songs will be printed yet.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_festival.c
1511 style cs_festival.h
1511 style main.c
1511 autotest-stage 01 cs_festival
give cs1511 ass2_cs_festival cs_festival.c cs_festival.h main.c

Stage 2

Stage 2 implements the core functionality of CS Festival planner.

This milestone has been divided into four substages:

  • Stage 2.1 - Append Performance.
  • Stage 2.2 - Insert Song.
  • Stage 2.3 - Print Most Popular Performance.
  • Stage 2.4 - Print Band Summary.

Stage 2.1 - Append Performance

In Stage 1, we introduced adding stages to our festival, but what is a festival without performances! In stage 2.1 , you will be implementing the functionality to append a performance to a stage.

Command

a p [stage_name: string] [band_name: string] [genre: string] [max_duration: int]

The append performance command consists of "a p" followed by the stage name to append the performance to, the name of the band performing, the genre of the performance, and the maximum duration of the performance in minutes. For example:

a p Forever ACDC ROCK 90

would append a performance named ACDC, has the genre ROCK and maximum duration of 90 minutes to the stage named Forever.

Description

When an append performance command is entered, your program should:

  1. Scan in from the user:

    • The stage's name with the provided scan_name() function.
    • The name of the band performing with the provided scan_name() function.
    • The performance's genre with the provided scan_genre() function.
    • The max duration.
  2. Find the stage in the festival's stage list that has a name matching the scanned [stage_name].

  3. Create a new performance where:

    • start_time is the end time of the last performance added to the stage, plus 10 minutes for the intermission.
      • If there are no other performances on the stage, the start_time is 0.
    • end_time is the start time of the performance, plus the max_duration.
  4. Append the performance to the tail of the stage's performance list.

  5. Print a message to confirm that the command was successful:
    "Performance for band '[band_name]' added to stage '[stage_name]'.\n".

Appending a performance a p Forever ACDC ROCK 90 should look something like this:

Before:

02_01_append_performance_before

After:

02_01_append_performance_after

Errors

When appending a performance, if any of the following conditions are met then the performance should not be added, and the corresponding error message should be printed out instead:

  • If the stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name]' found.\n".

  • If the genre is not a valid genre (scan_genre will return INVALID_GENRE):
    "ERROR: Invalid genre.\n".

  • If the max_duration is not positive:
    "ERROR: Duration must be positive.\n".

  • If the band already has a performance on the given stage:
    "ERROR: Performance for band '[band_name]' already exists on stage '[stage_name]'.\n".

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  (no songs yet)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  (no songs yet)

01:40 - 03:00 | Twice (Pop)
  (no songs yet)

Enter command: q
Goodbye!

Clarifications

  • You may assume the inputs for [stage_name], [band_name], [genre] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • [max_duration] is an integer.
  • A positive number is a number strictly greater than 0.

Stage 2.2 - Insert Song

Now that you can add performances, the next step is to implement the functionality to add songs to the festival plan.

Command

i g [stage_name: string] [band_name: string] [title: string] [duration: double] [popularity: int] [n: int]

The insert song command consists of "i g" followed by the performance details, the song details and the song's [position] in the setlist. For example, the command:

i g Forever ACDC Thunderstruck 3.5 10 2

would insert a song under the performance by the band ACDC on stage Forever at position 2 in the setlist. The song is named Thunderstruck, has duration 3.5 minutes and popularity 10

Description

When an insert song command is entered, your program should:

  1. Find the stage that matches the [stage_name].

  2. Find the performance on that stage that matches the [band_name].

  3. Create a new song and insert it into the performance's setlist according to the following rules:

    • If position <= 1
      then the new song should be inserted at the head of the setlist.
    • If position == n
      then after insertion, the new song should be the n-th song in the setlist.
    • If position is greater than the number of songs in the setlist
      then the new song should be inserted at the tail of the setlist.

After inserting a song, print a message to confirm that the command was successful:
"Song '[title]' added to performance for band '[band_name]' on stage '[stage_name]'.\n".

Inserting a new song i g Forever ACDC Thunderstruck 3.5 10 2 should look something like this:

Before:

02_02_insert_song_before

After:

02_02_insert_song_after

Errors

When inserting a song, if any of the following conditions are met then the song should not be inserted, and the corresponding error message should be printed out instead:

  • If the stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name]' found.\n".

  • If the band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name]' found on stage '[stage_name]'.\n".

  • If the popularity is not between 1 and 10 inclusive:
    "ERROR: Song popularity must be between 1 and 10 (inclusive).\n".

  • If the duration is not positive:
    "ERROR: Duration must be positive.\n".

  • If a song with the same title, duration and popularity already exists in the setlist it is being added to:
    "ERROR: Song '[title]' with duration '[duration]' and popularity '[popularity]' already exists in the setlist.\n".

  • If adding the new song causes the total duration of all songs in the list to exceed the performance’s maximum duration:
    "ERROR: Adding song would exceed max duration of performance for band '[band_name]'.\n".

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 3.5 10 1
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 3.5 10 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (3.5 mins, 10)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 3.5 10 3
i g Forever ACDC TNT 3.0 9 1
p
i g Forever ACDC Highway_to_Hell 3.8 8 1
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 3.5 10 3
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.0 9 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.0 mins, 9)
  2. Thunderstruck (3.5 mins, 10)

Enter command: i g Forever ACDC Highway_to_Hell 3.8 8 1
Song 'Highway_to_Hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Highway_to_Hell (3.8 mins, 8)
  2. TNT (3.0 mins, 9)
  3. Thunderstruck (3.5 mins, 10)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC TNT 3.0 9 1
i g Forever ACDC Highway_to_Hell 3.8 8 2
p
i g Forever ACDC Thunderstruck 3.5 10 2
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.0 9 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_Hell 3.8 8 2
Song 'Highway_to_Hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.0 mins, 9)
  2. Highway_to_Hell (3.8 mins, 8)

Enter command: i g Forever ACDC Thunderstruck 3.5 10 2
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.0 mins, 9)
  2. Thunderstruck (3.5 mins, 10)
  3. Highway_to_Hell (3.8 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 20
i g Forever ACDC Thunderstruck 3.5 10 1
i g Forever ACDC TNT 3.0 9 2
i g Forever ACDC Highway_to_Hell 3.8 8 3
i g Forever ACDC Back_In_Black 3.8 8 10
p
i g Forever ACDC Hells_Bells 5.0 4 2
p
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 20
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 3.5 10 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.0 9 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_Hell 3.8 8 3
Song 'Highway_to_Hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Back_In_Black 3.8 8 10
Song 'Back_In_Black' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 00:20 | ACDC (Rock)
  1. Thunderstruck (3.5 mins, 10)
  2. TNT (3.0 mins, 9)
  3. Highway_to_Hell (3.8 mins, 8)
  4. Back_In_Black (3.8 mins, 8)

Enter command: i g Forever ACDC Hells_Bells 5.0 4 2
Song 'Hells_Bells' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 00:20 | ACDC (Rock)
  1. Thunderstruck (3.5 mins, 10)
  2. Hells_Bells (5.0 mins, 4)
  3. TNT (3.0 mins, 9)
  4. Highway_to_Hell (3.8 mins, 8)
  5. Back_In_Black (3.8 mins, 8)

Enter command: q
Goodbye!

Clarifications

  • You may assume the inputs for [stage_name], [band_name], [title] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • [position] is an integer.
  • [duration] is a double.
  • Positions are 1-indexed. That is, a node at the head of a list is in position 1.
  • We will only test durations to 1 decimal place as the print_song() helper function formats durations this way.
  • Band name comparisons are case-sensitive. For example, "UNSW" and "unsw" are treated as two distinct performances.

Stage 2.3 - Print Most Popular Performance

In this stage, you will implement a command to print the most popular performance(s) in the festival.

Command

*

Description

When the print most popular performance command is entered, your program should:

  1. Print a banner "======== Popular performances ========\n".
  2. Print the details of the performance(s) with the highest average popularity of songs in its setlist, including:
    • The name of the stage it's on using print_stage_title().
    • The performance details, using print_performance_header() and your print_setlist() function.

If there is more than one performance with the same average popularity, all performances with that popularity should be printed.

If there are no performances in the festival plan yet, print:
"No performances found.\n".
This includes cases where there are no stages in the festival.

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
*
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: *
======== Popular performances ========
==========================================
[Forever]
00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
a p Forever Outkast HIPHOP 70
a p Forever Beyonce COUNTRY 75
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Forever Twice Signal 3.5 7 1
i g Forever Twice Fancy 3.8 9 2
i g Forever Outkast Hey_Ya 4.2 8 1
i g Forever Beyonce Texas_Hold_Em 3.4 7 1
*
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: a p Forever Outkast HIPHOP 70
Performance for band 'Outkast' added to stage 'Forever'.
Enter command: a p Forever Beyonce COUNTRY 75
Performance for band 'Beyonce' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 7 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: i g Forever Twice Fancy 3.8 9 2
Song 'Fancy' added to performance for band 'Twice' on stage 'Forever'.
Enter command: i g Forever Outkast Hey_Ya 4.2 8 1
Song 'Hey_Ya' added to performance for band 'Outkast' on stage 'Forever'.
Enter command: i g Forever Beyonce Texas_Hold_Em 3.4 7 1
Song 'Texas_Hold_Em' added to performance for band 'Beyonce' on stage 'Forever'.
Enter command: *
======== Popular performances ========
==========================================
[Forever]
00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)

==========================================
[Forever]
01:40 - 03:00 | Twice (Pop)
  1. Signal (3.5 mins, 7)
  2. Fancy (3.8 mins, 9)

==========================================
[Forever]
03:10 - 04:20 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
*
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: *
No performances found.
Enter command: q
Goodbye!

Clarifications

  • Performances should be printed in the order they appear from the head of the stage list, and if they are on the same stage, in the order they appear from the head of the stage's performance list.
  • Popularity averages should be computed as double-precision values.
  • If a performance has no songs, the average popularity is 0.

Stage 2.4 - Print Band Summary

In this stage, you will implement a command to see an overview of performances for a particular band.

Command

P [band_name: string]

The print band summary command consists of "P" followed by the name of the band that you want to print a summary for.

P ACDC

would print a summary of performances by ACDC.

Description

When a print band summary command is entered, your program should print:

  1. The band name.
  2. The total number of performances a band has across the entire festival plan.
  3. For each performance by the band, display the stage it's on (using print_stage_title()), the performance details (using print_performance_header()) and the setlist.

If there are no performances for the given band, print:
"No performances found for band '[band_name]'.\n".
This includes cases where there are no performances on the given band, or when there are no stages in the festival.

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
i g Forever ACDC Thunderstruck 4.5 9 1
i g Forever ACDC TNT 3.2 8 2
i g Forever Twice Signal 3.5 7 1
P ACDC
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 9 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 8 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 7 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: P ACDC
Band: ACDC
Total Performances: 1

==========================================
[Forever]
00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 9)
  2. TNT (3.2 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a p Forever ACDC ROCK 90
a p Always Twice POP 50
a p Live ACDC ROCK 60
a p Always Beyonce COUNTRY  55
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 8 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Always Twice Signal 3.5 8 1
i g Always Twice Fancy 3.8 9 2
i g Live ACDC Back_in_Black 4.1 7 1
i g Live ACDC For_Those_About_to_Rock 4.5 10 2
i g Always Beyonce Texas_Hold_Em 3.4 7 1
i g Always Beyonce Cowboy_Carter 4.0 8 2
i g Always Beyonce Sixteen_Carriages 3.8 9 3
P ACDC
P Twice
P Beyonce
q

Input and Output:

dcc main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always Twice POP 50
Performance for band 'Twice' added to stage 'Always'.
Enter command: a p Live ACDC ROCK 60
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Always Beyonce COUNTRY  55
Performance for band 'Beyonce' added to stage 'Always'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 8 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always Twice Signal 3.5 8 1
Song 'Signal' added to performance for band 'Twice' on stage 'Always'.
Enter command: i g Always Twice Fancy 3.8 9 2
Song 'Fancy' added to performance for band 'Twice' on stage 'Always'.
Enter command: i g Live ACDC Back_in_Black 4.1 7 1
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Live'.
Enter command: i g Live ACDC For_Those_About_to_Rock 4.5 10 2
Song 'For_Those_About_to_Rock' added to performance for band 'ACDC' on stage 'Live'.
Enter command: i g Always Beyonce Texas_Hold_Em 3.4 7 1
Song 'Texas_Hold_Em' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Always Beyonce Cowboy_Carter 4.0 8 2
Song 'Cowboy_Carter' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Always Beyonce Sixteen_Carriages 3.8 9 3
Song 'Sixteen_Carriages' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: P ACDC
Band: ACDC
Total Performances: 2

==========================================
[Live]
00:00 - 01:00 | ACDC (Rock)
  1. Back_in_Black (4.1 mins, 7)
  2. For_Those_About_to_Rock (4.5 mins, 10)

==========================================
[Forever]
00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 8)
  3. Highway_to_hell (4.1 mins, 9)

Enter command: P Twice
Band: Twice
Total Performances: 1

==========================================
[Always]
00:00 - 00:50 | Twice (Pop)
  1. Signal (3.5 mins, 8)
  2. Fancy (3.8 mins, 9)

Enter command: P Beyonce
Band: Beyonce
Total Performances: 1

==========================================
[Always]
01:00 - 01:55 | Beyonce (Country)
  1. Texas_Hold_Em (3.4 mins, 7)
  2. Cowboy_Carter (4.0 mins, 8)
  3. Sixteen_Carriages (3.8 mins, 9)

Enter command: q
Goodbye!

Clarifications

  • [band_name] is a string with length less than MAX_SIZE and will not contain spaces.
  • Performances should be printed in the order they appear from the head of the stage list.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_festival.c
1511 style cs_festival.h
1511 style main.c
1511 autotest-stage 02 cs_festival
give cs1511 ass2_cs_festival cs_festival.c cs_festival.h main.c

Stage 3

Stage 3 will focus on deleting nodes and memory management. This milestone has been divided into five substages:

  • Stage 3.1 - Cancel Festival Plan.
  • Stage 3.2 - Remove Stage and Performance.
  • Stage 3.3 - Remove Song.
  • Stage 3.4 - Update Performance Duration.
  • Stage 3.5 - Move Performance.

Stage 3.1 - Cancel Festival Plan

In this stage, you will ensure CS Festival can be closed by traversing every list and freeing all allocated memory before the program exits.

Description

From this stage onwards, when a quit 'q' command is entered, your program should free any memory that was allocated with malloc() before the program exits.

Examples

Input:

UNSW
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a p Forever ACDC ROCK 90
a p Always Twice POP 50
a p Live ACDC ROCK 60
a p Always Beyonce COUNTRY  55
a p Live Babymetal METAL 30
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 8 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Always Twice Signal 3.5 8 1
i g Always Twice Fancy 3.8 9 2
i g Live ACDC Back_in_Black 4.1 7 1
i g Live ACDC For_Those_About_to_Rock 4.5 10 2
i g Always Beyonce Texas_Hold_Em 3.4 7 1
i g Always Beyonce Cowboy_Carter 4.0 8 2
i g Always Beyonce Sixteen_Carriages 3.8 9 3
i g Live Babymetal Gimme_Chocolate 3.5 8 1
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always Twice POP 50
Performance for band 'Twice' added to stage 'Always'.
Enter command: a p Live ACDC ROCK 60
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Always Beyonce COUNTRY  55
Performance for band 'Beyonce' added to stage 'Always'.
Enter command: a p Live Babymetal METAL 30
Performance for band 'Babymetal' added to stage 'Live'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 8 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always Twice Signal 3.5 8 1
Song 'Signal' added to performance for band 'Twice' on stage 'Always'.
Enter command: i g Always Twice Fancy 3.8 9 2
Song 'Fancy' added to performance for band 'Twice' on stage 'Always'.
Enter command: i g Live ACDC Back_in_Black 4.1 7 1
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Live'.
Enter command: i g Live ACDC For_Those_About_to_Rock 4.5 10 2
Song 'For_Those_About_to_Rock' added to performance for band 'ACDC' on stage 'Live'.
Enter command: i g Always Beyonce Texas_Hold_Em 3.4 7 1
Song 'Texas_Hold_Em' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Always Beyonce Cowboy_Carter 4.0 8 2
Song 'Cowboy_Carter' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Always Beyonce Sixteen_Carriages 3.8 9 3
Song 'Sixteen_Carriages' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Live Babymetal Gimme_Chocolate 3.5 8 1
Song 'Gimme_Chocolate' added to performance for band 'Babymetal' on stage 'Live'.
Enter command: q
Goodbye!

Clarifications

In this stage, and in all subsequent stages:

  • Autotests and marking tests will check for memory leaks by compiling with
    dcc --leak-check.
  • If your code allocates memory with malloc() but does not free it with free() before the program terminates, your program will fail autotests and final marking tests.

Stage 3.2 - Remove Stage and Performance

In this stage, you introduce removing stages and performances.

Command 1: Remove Performance

x p [stage_name: string] [band_name: string]

The remove performance command consists of "x p" followed by the [stage_name] of the stage which the performance is on, and the [band_name] of the performance. For example, the command:

x p Forever ACDC

would remove the performance on stage Forever with a band name ACDC.

Description

When the remove performance command is entered, the program should remove the performance matching the provided band name from the list of performances on the specified stage.

Since each performance must begin 10 minutes after the previous performance ends, removing a performance will require you to recalculate and update the start and end times of performances in the list to maintain this rule.

When the remove performance command is complete, the program should print:
"Performance for band '[band_name]' removed from stage '[stage_name]'.\n".

Errors

When removing a performance, if any of the following conditions are met, the corresponding error message should be printed out instead:

  • If the stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name]' found.\n".

  • If the band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name]' found on stage '[stage_name]'.\n".

Command 2: Remove Stage

x s [stage_name: string]

The remove stage command consists of "x s" followed by the [stage_name] of the stage to be removed. For example, the command:

x s Forever

would remove the stage with the name Forever.

Description

When a remove stage command is entered, your program should remove the stage matching the provided name from the festival's stage list, freeing all performances planned on that stage and the stage itself.

When the remove stage command is complete, the program should print:
"Stage '[stage_name]' removed.\n".

Errors

When removing a stage, if the stage name does not match an existing stage, the error message "ERROR: No stage with name '[stage_name]' found.\n" should be printed instead.

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
p
x p Forever ACDC
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)

Enter command: x p Forever ACDC
Performance for band 'ACDC' removed from stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]
  (no performances yet)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
a p Forever Outkast HIPHOP 70
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever Twice Signal 3.5 9 1
i g Forever Outkast Hey_Ya 4.2 6 1
p
x p Forever Twice
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: a p Forever Outkast HIPHOP 70
Performance for band 'Outkast' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 9 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: i g Forever Outkast Hey_Ya 4.2 6 1
Song 'Hey_Ya' added to performance for band 'Outkast' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 03:00 | Twice (Pop)
  1. Signal (3.5 mins, 9)

03:10 - 04:20 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

Enter command: x p Forever Twice
Performance for band 'Twice' removed from stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 02:50 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
p
x s Forever
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: p
Festival: UNSW
==========================================
[Forever]
  (no performances yet)

Enter command: x s Forever
Stage 'Forever' removed.
Enter command: p
Festival: UNSW
  (no stages yet)
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a p Forever ACDC ROCK 90
a p Always Twice POP 50
a p Live Outkast HIPHOP 65
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always Twice Signal 3.5 9 1
i g Live Outkast Hey_Ya 4.2 6 1
p
x s Forever
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always Twice POP 50
Performance for band 'Twice' added to stage 'Always'.
Enter command: a p Live Outkast HIPHOP 65
Performance for band 'Outkast' added to stage 'Live'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always Twice Signal 3.5 9 1
Song 'Signal' added to performance for band 'Twice' on stage 'Always'.
Enter command: i g Live Outkast Hey_Ya 4.2 6 1
Song 'Hey_Ya' added to performance for band 'Outkast' on stage 'Live'.
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 01:05 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

==========================================
[Always]

00:00 - 00:50 | Twice (Pop)
  1. Signal (3.5 mins, 9)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: x s Forever
Stage 'Forever' removed.
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 01:05 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

==========================================
[Always]

00:00 - 00:50 | Twice (Pop)
  1. Signal (3.5 mins, 9)

Enter command: q
Goodbye!

Clarifications

  • You may assume the inputs for [stage_name], [band_name] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • When a stage or performance is removed, all associated memory (including their performances, and the performances' setlists) should be freed.
  • Stage and band name comparisons are case-sensitive. For example, "UNSW" and "unsw" are treated as two distinct stages/performances.

Stage 3.3 - Remove Song

In this stage, you allow CS Festival to remove a song from a particular position in a performance's setlist.

Command

x g [stage_name: string] [band_name: string] [position: int]

The remove song command consists of "x g" followed by the performance details, and the song's [position] in the setlist. For example, the command:

x g Forever ACDC 2

would remove the song from under the performance by the band ACDC on stage Forever at position 2 in the setlist.

Description

When the remove song command is entered, your program should remove the song at position [position] in the setlist associated with the provided the stage and band name.

When the remove song command is complete, the program should print:
"Song '[song_name]' removed from performance for band '[band_name]' on stage '[stage_name]'.\n".

Errors

When removing a song, if any of the following conditions are met then the song should not be removed, and the corresponding error message should be printed instead:

  • If the stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name]' found.\n".

  • If the band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name]' found on stage '[stage_name]'.\n".

  • If the performance's setlist is empty:
    "ERROR: Performance for band '[band_name]' has no songs to remove.\n".

  • If the position does not correspond to a song in the setlist (i.e. is not positive, or is greater than the number of songs in the setlist):
    "ERROR: Invalid song position '[position]' for performance of band '[band_name]'.\n".

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Forever ACDC Back_in_Black 3.8 10 4
p
x g Forever ACDC 2
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Back_in_Black 3.8 10 4
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)
  4. Back_in_Black (3.8 mins, 10)

Enter command: x g Forever ACDC 2
Song 'TNT' removed from performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. Highway_to_hell (4.1 mins, 9)
  3. Back_in_Black (3.8 mins, 10)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Forever ACDC Back_in_Black 3.8 10 4
i g Forever ACDC For_Those_About_to_Rock 4.0 6 5
p
x g Forever ACDC 3
p
x g Forever ACDC 1
p
x g Forever ACDC 2
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Back_in_Black 3.8 10 4
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC For_Those_About_to_Rock 4.0 6 5
Song 'For_Those_About_to_Rock' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)
  4. Back_in_Black (3.8 mins, 10)
  5. For_Those_About_to_Rock (4.0 mins, 6)

Enter command: x g Forever ACDC 3
Song 'Highway_to_hell' removed from performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Back_in_Black (3.8 mins, 10)
  4. For_Those_About_to_Rock (4.0 mins, 6)

Enter command: x g Forever ACDC 1
Song 'Thunderstruck' removed from performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.2 mins, 7)
  2. Back_in_Black (3.8 mins, 10)
  3. For_Those_About_to_Rock (4.0 mins, 6)

Enter command: x g Forever ACDC 2
Song 'Back_in_Black' removed from performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.2 mins, 7)
  2. For_Those_About_to_Rock (4.0 mins, 6)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
p
x g NonExistent ACDC 1
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: x g NonExistent ACDC 1
ERROR: No stage with name 'NonExistent' found.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: q
Goodbye!

Clarifications

  • You may assume the inputs for [stage_name] and [band_name] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • When a song is removed from a performance's setlist, all its associated memory should be freed.
  • A positive number is a number strictly greater than 0.

Stage 3.4 - Update Performance Duration

In Stage 3.4 you will implement a function to update the maximum duration of a performance.

Command

u [stage_name: string] [band_name: string] [new_duration: int]

The update performance duration command consists of "u" followed by the performance details, and the [new_duration] that the performance will have. For example, the command:

u Forever ACDC 120

would update the maximum duration of performance by band ACDC on stage Forever to be 120 minutes.

Description

When the update performance duration command is entered, your program should:

  1. Update the maximum duration of the performance specified.
  2. If the new duration is less than the current maximum duration of the performance, remove songs from the end of the setlist until the setlist fits within the new duration.
  3. If the new duration is greater than the current maximum duration, Leave the setlist unchanged (additional songs can be added in future commands).
  4. Recalculate and update the start and end times of this and all subsequent performances on the stage, ensuring that each performance begins 10 minutes after the previous performance ends.

When the update performance duration command is complete, the program should print:
"Performance for band '[band_name]' on stage '[stage_name]' updated to max duration '[new_duration]' minutes.\n".

Errors

When updating a performance's duration, if any of the following conditions are met then the performance should not be updated, and the corresponding error message should be printed instead:

  • If the stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name]' found.\n".

  • If the band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name]' found on stage '[stage_name]'.\n".

  • If the new duration is not positive:
    "ERROR: Duration must be positive.\n".

Examples

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
i g Forever ACDC Highway_to_hell 4.1 9 3
p
u Forever ACDC 95
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)

Enter command: u Forever ACDC 95
Performance for band 'ACDC' on stage 'Forever' updated to max duration 95 minutes.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:35 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever ACDC TNT 3.2 7 2
i g Forever ACDC Highway_to_hell 4.1 9 3
i g Forever ACDC Back_in_Black 3.8 10 4
p
u Forever ACDC 12
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC TNT 3.2 7 2
Song 'TNT' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Highway_to_hell 4.1 9 3
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever ACDC Back_in_Black 3.8 10 4
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)
  4. Back_in_Black (3.8 mins, 10)

Enter command: u Forever ACDC 12
Performance for band 'ACDC' on stage 'Forever' updated to max duration 12 minutes.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 00:12 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)
  2. TNT (3.2 mins, 7)
  3. Highway_to_hell (4.1 mins, 9)

Enter command: q
Goodbye!

Clarifications

  • You may assume the inputs for [stage_name] and [band_name] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • [new_duration] is an integer.
  • When a song is removed from a performance's setlist, all its associated memory should be freed.
  • A positive number is a number strictly greater than 0.

Stage 3.5 - Move Performance

In Stage 3.5 you will implement a function to move a performance from one stage to another.

Command

m [src_stage_name: string] [dest_stage_name: string] [band_name: string] [position: int]

The move performance command consists of "m" followed by the source stage name, the destination stage name, the band name of the performance to be moved, and the integer [position] where the performance should be inserted on the destination stage.

m Forever Lightning ACDC 4

would move the performance by band ACDC from stage Forever to stage Lightning, at position 4.

Description

When the move performance command is entered, your program should:

  1. Move the performance from the source stage into the destination stage at the requested [position] according to the following rules:

    • If position <= 1
      then the performance should be inserted at the head of the performance list.
    • If position == n
      then after insertion, the performance should be the n-th performance in the performance list.
    • If position is greater than the number of performances in the performance list
      then the performance should be inserted at the tail of the performance list.
  2. Recalculate the start and end times of performances on the destination stage to ensure that each performance starts 10 minutes after the previous performance ends.

  3. Recalculate the start and end times of performances on the source stage, since removing a performance may also shift their timings.

After the command is complete, print the confirmation message:
"Performance for band '[band_name]' moved from stage '[src_stage_name]' to stage '[dest_stage_name]' at position '[position]'.\n", where [position] is the position that the performance was moved to (not necessarily the position from the command).

Errors

When moving a performance, if any of the following conditions are met then the performance should not be moved, and the corresponding error message should be printed instead:

  • If the source stage does not exist:
    "ERROR: No stage with name '[src_stage_name]' found.\n".

  • If the destination stage does not exist:
    "ERROR: No stage with name '[dest_stage_name]' found.\n".

  • If the band does not have a performance on the source stage:
    "ERROR: No performance for band '[band_name]' found on stage '[src_stage_name]'.\n".

  • If the band already has a performance on the destination stage (only if the destination stage is NOT the same as the source stage):
    "ERROR: Performance for band '[band_name]' already exists on stage '[dest_stage_name]'.\n".

Examples

Input:

UNSW
a s Forever
a s Always
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever Twice Signal 3.5 9 1
p
m Forever Always ACDC 1
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 9 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Always]
  (no performances yet)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 03:00 | Twice (Pop)
  1. Signal (3.5 mins, 9)

Enter command: m Forever Always ACDC 1
Performance for band 'ACDC' moved from stage 'Forever' to stage 'Always' at position '1'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

==========================================
[Forever]

00:00 - 01:20 | Twice (Pop)
  1. Signal (3.5 mins, 9)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
a p Forever Outkast HIPHOP 70
a p Always Beyonce COUNTRY 55
a p Always Babymetal METAL 200
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever Twice Signal 3.5 9 1
i g Forever Outkast Hey_Ya 4.2 6 1
i g Always Beyonce Texas_Hold_Em 3.4 7 1
i g Always Babymetal Gimme_Chocolate 3.5 8 1
p
m Forever Always Twice 5
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: a p Forever Outkast HIPHOP 70
Performance for band 'Outkast' added to stage 'Forever'.
Enter command: a p Always Beyonce COUNTRY 55
Performance for band 'Beyonce' added to stage 'Always'.
Enter command: a p Always Babymetal METAL 200
Performance for band 'Babymetal' added to stage 'Always'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 9 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: i g Forever Outkast Hey_Ya 4.2 6 1
Song 'Hey_Ya' added to performance for band 'Outkast' on stage 'Forever'.
Enter command: i g Always Beyonce Texas_Hold_Em 3.4 7 1
Song 'Texas_Hold_Em' added to performance for band 'Beyonce' on stage 'Always'.
Enter command: i g Always Babymetal Gimme_Chocolate 3.5 8 1
Song 'Gimme_Chocolate' added to performance for band 'Babymetal' on stage 'Always'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 00:55 | Beyonce (Country)
  1. Texas_Hold_Em (3.4 mins, 7)

01:05 - 04:25 | Babymetal (Metal)
  1. Gimme_Chocolate (3.5 mins, 8)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 03:00 | Twice (Pop)
  1. Signal (3.5 mins, 9)

03:10 - 04:20 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

Enter command: m Forever Always Twice 5
Performance for band 'Twice' moved from stage 'Forever' to stage 'Always' at position '3'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 00:55 | Beyonce (Country)
  1. Texas_Hold_Em (3.4 mins, 7)

01:05 - 04:25 | Babymetal (Metal)
  1. Gimme_Chocolate (3.5 mins, 8)

04:35 - 05:55 | Twice (Pop)
  1. Signal (3.5 mins, 9)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 02:50 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a p Forever ACDC ROCK 90
a p Forever Twice POP 80
a p Forever Outkast HIPHOP 70
a p Forever Beyonce COUNTRY 55
i g Forever ACDC Thunderstruck 4.5 8 1
i g Forever Twice Signal 3.5 9 1
i g Forever Outkast Hey_Ya 4.2 6 1
i g Forever Beyonce Texas_Hold_Em 3.4 7 1
p
m Forever Forever Twice 3
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Twice POP 80
Performance for band 'Twice' added to stage 'Forever'.
Enter command: a p Forever Outkast HIPHOP 70
Performance for band 'Outkast' added to stage 'Forever'.
Enter command: a p Forever Beyonce COUNTRY 55
Performance for band 'Beyonce' added to stage 'Forever'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Forever Twice Signal 3.5 9 1
Song 'Signal' added to performance for band 'Twice' on stage 'Forever'.
Enter command: i g Forever Outkast Hey_Ya 4.2 6 1
Song 'Hey_Ya' added to performance for band 'Outkast' on stage 'Forever'.
Enter command: i g Forever Beyonce Texas_Hold_Em 3.4 7 1
Song 'Texas_Hold_Em' added to performance for band 'Beyonce' on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 03:00 | Twice (Pop)
  1. Signal (3.5 mins, 9)

03:10 - 04:20 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

04:30 - 05:25 | Beyonce (Country)
  1. Texas_Hold_Em (3.4 mins, 7)

Enter command: m Forever Forever Twice 3
Performance for band 'Twice' moved from stage 'Forever' to stage 'Forever' at position '3'.
Enter command: p
Festival: UNSW
==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 02:50 | Outkast (Hip Hop)
  1. Hey_Ya (4.2 mins, 6)

03:00 - 04:20 | Twice (Pop)
  1. Signal (3.5 mins, 9)

04:30 - 05:25 | Beyonce (Country)
  1. Texas_Hold_Em (3.4 mins, 7)

Enter command: q
Goodbye!

Clarifications

  • The source and destination stages do not need to be distinct, i.e. it is possible to move a performance to a different (or same) position on the same stage. The position number should be calculated based on the performance list including the performance being moved. For example, if the list is:

    ACDC -&gt; Taylor Swift -&gt; The Beatles

    and we are moving ACDC, ACDC will still count as position 1. This ensures the performance's position after moving is the same as the position the user specifies.

  • You may assume the inputs for [src_stage_name], [dest_stage_name] and [band_name] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.

  • [position] is an integer.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_festival.c
1511 style cs_festival.h
1511 style main.c
1511 autotest-stage 03 cs_festival
give cs1511 ass2_cs_festival cs_festival.c cs_festival.h main.c

Stage 4

This stage is for students who want to challenge themselves and solve more complicated programming problems. This milestone has been divided into two substages:

  • Stage 4.1 - Join Performances.
  • Stage 4.2 - Scheduling Conflicts.

Stage 4.1 - Join Performances

In this stage you will implement a function to merge two performances of the same genre into a single joint performance.

Command

 
j [stage_name1: string] [band_name1: string] [stage_name2: string] [band_name2: string]

The join performances command consists of "j" followed by the stage and band names of the two performances to be merged.

For example, the command:

 j Forever ACDC Lightning Metallica 

would join the performance by ACDC on stage Forever and the performance by Metallica on stage Lightning into a single joint performance.

Description

Identifying the headliner and the supporting act

The joint performance will conceptually consist of a headliner and a supporting act, which is determined based on the average popularities of each performance's setlists.

  • The headliner is the performance with the greater average popularity.
  • If the popularities are the same, the band named first in the command will be the headliner by default. The other act will then, by effect, become the supporting act.

The joint performance replaces the headliner's original performance position in its stage. After this replacement, both of the original performances are removed from their stages, leaving only the joint performance in the schedule.

Creating the joint band name

The band name of the joint performance is formed by combining portions of the two original names, using the following rules:

  1. Split each band’s name into halves.
  2. From the headlining band's name, take all characters from the start of the name up to and including the last vowel in the first half. If there are no such vowels, all the characters in the first half of the name should be taken.
  3. From the supporting band’s name, take all characters starting from the first consonant in the second half. If there are no such consonants, all of the characters in the second half should be taken.
  4. Concatenate these two parts to form the new band name.

Example:

Considering two band names, Cocteau_Twins and Duster, where Cocteau_Twins is the headliner and Duster is the supporting act:

  1. Cocteau_Twins has an odd number of characters, hence it has first half: "Cocteau" and second half: "_Twins". Duster has an even number of characters, hence has first half: "Dus" and second half: "ter".
  2. The last vowel in the first half of Cocteau_Twins is 'u', so the portion kept is "Cocteau"
  3. The first consonant in the second half of Duster is 't', thus the portion kept is "ter"
  4. Concatenating the two portions results in "Cocteauter" as the name of the new, joint performance.

Joining two performances with the join command "j" should look something like this:

Before:

join_performance_before

After:

join_performance_after

Merging the setlists

Finally, to merge the setlists, songs should be interleaved according to the popularity ratio of the two bands:

  1. Start with one song from the supporting act.
  2. After each supporting act song, insert songs from the headliner. The number of headliner songs to insert is determined by the popularity ratio, calculated using the formula:
    ceil(headliner_popularity / supporting_popularity)
  3. Repeat this pattern until one of the setlists has no more songs left.
  4. If one of the two setlists being merged has run out of songs, append any remaining songs from the other list in their original order.

For example, if Band A has an average popularity of 7, and Band B has an average popularity of 3, then the bands have a popularity ratio of 7:3.

Hence, every song by Band B should be followed by 3 songs by Band A.

If Band A had 8 songs, and Band B had 2 songs, then in the new setlist, every song by Band B will be followed by 3 songs by Band A. This pattern can continue until both songs by Band B are in the new setlist:

  • B → A → A → A → B → A → A → A

Finally, the remaining 2 songs by band A that have not been added to the new setlist, will be appended to the end of the list:

  • B → A → A → A → B → A → A → A → A → A

The max duration of a joint performance is the sum of the max durations of the two original performances.

Once the command is complete, print the confirmation message:
"Joint performance '[band_name]' created on stage '[stage_name]'.\n".

Where [band_name] is the newly created name, and [stage_name] is the name of the stage the joint performance is on.

Merging the setlists of two performances with the join command "j" should look something like this:

Before:

merge_setlist_before

After:

merge_setlist_after

Errors

  • If the first stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name1]' found.\n".

  • If the first band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name1]' found on stage '[stage_name1]'.\n".

  • If the second stage name does not match an existing stage:
    "ERROR: No stage with name '[stage_name2]' found.\n".

  • If the second band name does not match a band in the list of performances on the specified stage:
    "ERROR: No performance for band '[band_name2]' found on stage '[stage_name2]'.\n".

  • If the two named performances are not of the same genre:
    "ERROR: Joint performances can only be of the same genre.\n".

Examples

Input:

UNSW
a s Forever
a s Always
a p Forever BananaRepublic ROCK 90
a p Always Countermeasure ROCK 80
p
j Forever BananaRepublic Always Countermeasure
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever BananaRepublic ROCK 90
Performance for band 'BananaRepublic' added to stage 'Forever'.
Enter command: a p Always Countermeasure ROCK 80
Performance for band 'Countermeasure' added to stage 'Always'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 01:20 | Countermeasure (Rock)
  (no songs yet)

==========================================
[Forever]

00:00 - 01:30 | BananaRepublic (Rock)
  (no songs yet)

Enter command: j Forever BananaRepublic Always Countermeasure
Joint performance 'Bananameasure' created on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Always]
  (no performances yet)

==========================================
[Forever]

00:00 - 02:50 | Bananameasure (Rock)
  (no songs yet)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a p Forever ACDC ROCK 90
a p Always Kiss ROCK 80
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always Kiss Rock_And_Roll_All_Nite 4.2 6 1
p
j Forever ACDC Always Kiss
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always Kiss ROCK 80
Performance for band 'Kiss' added to stage 'Always'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always Kiss Rock_And_Roll_All_Nite 4.2 6 1
Song 'Rock_And_Roll_All_Nite' added to performance for band 'Kiss' on stage 'Always'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 01:20 | Kiss (Rock)
  1. Rock_And_Roll_All_Nite (4.2 mins, 6)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: j Forever ACDC Always Kiss
Joint performance 'Ass' created on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Always]
  (no performances yet)

==========================================
[Forever]

00:00 - 02:50 | Ass (Rock)
  1. Rock_And_Roll_All_Nite (4.2 mins, 6)
  2. Thunderstruck (4.5 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a p Forever Cocteau_Twins ROCK 120
a p Always Duster ROCK 100
i g Forever Cocteau_Twins Heaven_or_Las_Vegas 4.2 8 1
i g Forever Cocteau_Twins Carolyns_Fingers 3.8 7 2
i g Forever Cocteau_Twins Lorelai 3.5 6 3
i g Forever Cocteau_Twins Sugar_Hiccup 3.9 7 4
i g Forever Cocteau_Twins Cherry_Coloured_Funk 4.1 7 5
i g Forever Cocteau_Twins Iceblink_Luck 3.3 8 6
i g Forever Cocteau_Twins Violet_Indiana 3.7 6 7
i g Forever Cocteau_Twins Pandora 4.5 8 8
i g Always Duster Inside_Out 4.8 4 1
i g Always Duster Gold_Dust 5.2 3 2
p
j Forever Cocteau_Twins Always Duster
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever Cocteau_Twins ROCK 120
Performance for band 'Cocteau_Twins' added to stage 'Forever'.
Enter command: a p Always Duster ROCK 100
Performance for band 'Duster' added to stage 'Always'.
Enter command: i g Forever Cocteau_Twins Heaven_or_Las_Vegas 4.2 8 1
Song 'Heaven_or_Las_Vegas' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Carolyns_Fingers 3.8 7 2
Song 'Carolyns_Fingers' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Lorelai 3.5 6 3
Song 'Lorelai' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Sugar_Hiccup 3.9 7 4
Song 'Sugar_Hiccup' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Cherry_Coloured_Funk 4.1 7 5
Song 'Cherry_Coloured_Funk' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Iceblink_Luck 3.3 8 6
Song 'Iceblink_Luck' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Violet_Indiana 3.7 6 7
Song 'Violet_Indiana' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Forever Cocteau_Twins Pandora 4.5 8 8
Song 'Pandora' added to performance for band 'Cocteau_Twins' on stage 'Forever'.
Enter command: i g Always Duster Inside_Out 4.8 4 1
Song 'Inside_Out' added to performance for band 'Duster' on stage 'Always'.
Enter command: i g Always Duster Gold_Dust 5.2 3 2
Song 'Gold_Dust' added to performance for band 'Duster' on stage 'Always'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 01:40 | Duster (Rock)
  1. Inside_Out (4.8 mins, 4)
  2. Gold_Dust (5.2 mins, 3)

==========================================
[Forever]

00:00 - 02:00 | Cocteau_Twins (Rock)
  1. Heaven_or_Las_Vegas (4.2 mins, 8)
  2. Carolyns_Fingers (3.8 mins, 7)
  3. Lorelai (3.5 mins, 6)
  4. Sugar_Hiccup (3.9 mins, 7)
  5. Cherry_Coloured_Funk (4.1 mins, 7)
  6. Iceblink_Luck (3.3 mins, 8)
  7. Violet_Indiana (3.7 mins, 6)
  8. Pandora (4.5 mins, 8)

Enter command: j Forever Cocteau_Twins Always Duster
Joint performance 'Cocteauter' created on stage 'Forever'.
Enter command: p
Festival: UNSW
==========================================
[Always]
  (no performances yet)

==========================================
[Forever]

00:00 - 03:40 | Cocteauter (Rock)
  1. Inside_Out (4.8 mins, 4)
  2. Heaven_or_Las_Vegas (4.2 mins, 8)
  3. Carolyns_Fingers (3.8 mins, 7)
  4. Lorelai (3.5 mins, 6)
  5. Gold_Dust (5.2 mins, 3)
  6. Sugar_Hiccup (3.9 mins, 7)
  7. Cherry_Coloured_Funk (4.1 mins, 7)
  8. Iceblink_Luck (3.3 mins, 8)
  9. Violet_Indiana (3.7 mins, 6)
  10. Pandora (4.5 mins, 8)

Enter command: q
Goodbye!

Clarifications

  • You may assume that the name created upon merge will always be unique within the specified stage’s list of performances. In other words, the new name will not conflict with or duplicate the name of any existing band already scheduled on that stage.
  • You may assume that the name created upon merge will not exceed MAX_SIZE. This includes space for the null terminating character i.e. \0.
  • You may assume the inputs for [stage_name1], [band_name1], [stage_name2] and [band_name2] are strings that will not exceed MAX_SIZE . You may also assume these inputs will not contain spaces.
  • The midpoint of a name is the position that divides the string into two halves:
    • If the number of characters is even, the first half consists of all characters up to and including the character just before the midpoint, and the second half consists of all characters from the character just after the midpoint onward.
    • If the number of characters is odd, the first half consists of all characters up to and including this central character, and the second half consists of all characters from this central character onward.
    • If there is only a single character, both the first half and the second half is that character. For example, if a band name is "A", the first half is "A" and the second half is also "A".
  • The set of vowels is defined as: AEIOUaeiou. Any character not in this set is considered a consonant, including non-alphabetical, ASCII characters.
  • Popularity averages should be computed as double-precision values.
  • You will not be tested on the case where the first performance and the second performance are the same, e.g. j Forever ACDC Forever ACDC.

Stage 4.2 - Scheduling Conflicts

So far, CS Festival enables scheduling bands at the same time across different stages, which is clearly unrealistic! In this stage, you will implement a way to detect and attempt to resolve conflicts.

Definitions

  • Conflict: A conflict occurs when two performances by the same band are scheduled on different stages, and their time intervals overlap. It is also a conflict when two performances by the same band start and end at the same time.
  • Conflict group: A performance is part of a conflict group if it conflicts with at least one other performance in the group. For example for a conflict group consisting of performances A, B and C:
    • A conflicts with B
    • B conflicts with C
    • C does not necessarily have to conflict with A.

Command 1: View conflicts

 
c v [band_name: string] 

The view conflicts command consists of "c v" followed by a band name [band_name] of the band to print the conflicts of.

The command:

c v ACDC

would print conflicting performances for the band named ACDC.

Description

When the view conflicts command is entered, your program should:

  1. Print all conflict groups of a particular band:

    • A helper function, print_conflict_group_header() has been provided to format the heading for each conflict group. It takes in a single parameter, conflict_time, which is the start time of the earliest overlapping time period in the chain.

    For example, if a conflict chain includes performances from:

    • 1:00 to 2:00
    • 1:30 to 3:00, and
    • 2:30 to 4:00

    then the first overlap occurs between 1:30 and 2:00, so conflict_time will be 1:30.

    // Function to print a conflict group header
    // Params:
    //      conflict_time - the start time of the conflict group 
    //                      (in minutes from the start of the festival)
    // Returns: None
    // Usage example:
    // ```
    //      print_conflict_group_header(conflict_time);
    // ```
    void print_conflict_group_header(int conflict_time) {
        char buffer[MAX_SIZE];
        format_time(conflict_time, buffer);
        printf(
            "\nConflicts found from %s:\n-------------------------------------"
            "-----\n", buffer
        );
    }
    

  2. Then for each conflict group, print the details of each performance in order of start time.

    • If two performances conflict and start at the same time, print the performance with the shorter max duration, first.
    • If they also have the same max duration, print the performance on the stage closer to the head of the festival's stage list, first.
    • A helper function, print_conflict_performance() has been provided to format the conflicting performance details. It takes in two parameters, the stage_name of the performance being printed, and the performance itself.

    // Function to print a conflicting performance with its stage name
    // Params:
    //      stage_name  - the name of the stage the performance is on
    //      performance - a pointer to the performance
    // Returns: None
    // Usage example:
    // ```
    //      print_conflict_performance(stage_name, performance);
    // ```
    void print_conflict_performance(
        char stage_name[MAX_SIZE], 
        struct performance *performance
    ) {
        printf("    - [%s] ", stage_name);
        print_performance_header(performance);
    }
    

If there are no conflicting performances for the given band, print:
"No conflicts found for band '[band_name]'.\n".

Errors

  • If the band name does not match any performances in the festival, print:
    "ERROR: No performances found for band '[band_name]'.\n".

Command 2: Resolve Conflicts

 
c r [band_name: string] 

The resolve conflicts command consists of "c r" followed by the [band_name] of the band to resolve the conflicts of.

The command:

c r ACDC

would attempt to resolve conflicting performances for the band named ACDC.

Description

Conflicts are resolved by inserting an existing performance before one of the conflicting performances, thereby shifting it to a later time slot and eliminating the overlap. The inserted performance is called the buffer performance, and the performance being moved is the shifted performance.

The shifted performance will be the conflicting performance with the later start time. If both conflicting performances start at the same time, the shifted performance is the performance with the longer max duration. If they also have the same max duration, it is the performance on a stage closer to the tail of the festival's stage list.

When the resolve conflicts command is entered, the program should:

  1. Identify the first conflicting pair of performances for the given band following the order of conflicts from the view conflicts command, where the first conflict is defined as the first pair of performances, ordered by start time, where their scheduled time intervals conflict.

    • If there are multiple conflicts at the same time, the first conflict is the pair of performances with the two shortest durations. If they have the same duration, pick the pair closer to the head of the festival's stage list.
  2. Resolve the conflict by inserting a buffer performance in front of the shifted performance.

  3. Ensure the start and end times of performances on the buffer performance and shifted performance's stages maintain the 10-minute intermission rule.

  4. Repeat steps 1 to 3 until all conflicts are resolved, or there is a conflict that cannot be resolved.

If there are no conflicting pairs, then print:
"No conflicts to be resolved for band '[band_name]'.\n"
and terminate the command.

To select the buffer performance for each conflict in the resolution process, you will traverse through potential candidates as follows:

  1. Start considering performances from the tail of each stage's performance list (including the stage the buffer performance is on).
  2. Traverse stages over laps in a cyclic order (similar to a round-robin) until all possible performances have been considered. For each lap, visit the stages in order from the head of the stage list. Once you reach the tail of the stage list, move back to the head.
  3. Consider the last unvisited performance on each stage. A performance is unvisited if it has not been considered in previous laps.
  4. During traversal, if the current last performance on a stage is by a band involved in the current conflict, do not consider the remaining performances on that stage in this or future laps.

The traversal process resets for each new conflict during resolution. If a stage was excluded from consideration while selecting a buffer performance for one conflict (due to having a performance by the conflicting band), that stage becomes eligible again when resolving the next conflict.

Example traversal:

traversal_example

Considering the stages and performances above, if the conflicting pair is A1 and B2, the traversal order is A3, B3, C3, A2, C2, C1, where:

  • Lap 1: A3, B3, C3
  • Lap 2: A2, C2
    • (B2 is conflicting, so stop considering Stage B for future laps of traversal)
  • Lap 3: C1

During traversal, choose the best buffer performance using the following criteria:

  1. A performance is only valid if:
    • Its max duration is greater than or equal to the duration that the two performances overlap.
    • It is performed by a different band than the conflicting performances.
  2. Among valid performances, select the buffer performance using these priorities:
    • Select the performance whose max duration is closest to the duration that the two performances overlap.
    • If tied, prioritise selecting one with the same genre as the shifted performance.
    • If both or neither have the same genre as the shifted performance, select the earliest in traversal order.
  3. If no valid buffer performance is found, then the conflict cannot be resolved. So, terminate the command and print:
    "Not all conflicts could be resolved.\n".

To step through a single conflict being resolved, consider the following stages and performances where:

  • The performances highlighted in blue represent two conflicting performances for the band Duster, as the time intervals overlap for the 50-minute period between from 40 to 90 minutes from the start of the festival.
  • The performances highlighted in pink represent possible candidates for the buffer performance, numbered in the traversal order as described above. Notice that the performance by Twice on stage Laugh is grey as it is positioned above a performance by Duster.
before_conflict_resolution

The best match is the performance by Slowdive on the stage Live, as it's max duration, 50 minutes, is the closest to the overlap duration of the conflicting performances. Although KATSEYE's max duration is also 50 minutes, Slowdive's genre matches the genre of the conflicting performances, hence it is selected as the buffer performance.

Then, the buffer performance is inserted before Duster's performance on stage Laugh, as it has a later start time in the conflicting pair, and the conflict is resolved.

The state of the stages and performances after the conflict resolution is shown below:

after_conflict_resolution

Examples

Input:

UNSW
a s Forever
a s Always
a s Live
a s Electric
a s Laugh
a p Forever ACDC ROCK 80
a p Always ACDC ROCK 90
a p Laugh ACDC ROCK 90
a p Always Taylor POP 60
a p Live Mike COUNTRY 40
a p Live ACDC ROCK 70
a p Electric Beyonce COUNTRY 30
a p Electric ACDC ROCK 60
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always ACDC TNT 3.2 7 1
i g Live ACDC Highway_to_hell 4.1 9 1
i g Electric ACDC Back_in_Black 3.8 6 1
p
c v ACDC
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a s Electric
Stage 'Electric' added.
Enter command: a s Laugh
Stage 'Laugh' added.
Enter command: a p Forever ACDC ROCK 80
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Always'.
Enter command: a p Laugh ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Laugh'.
Enter command: a p Always Taylor POP 60
Performance for band 'Taylor' added to stage 'Always'.
Enter command: a p Live Mike COUNTRY 40
Performance for band 'Mike' added to stage 'Live'.
Enter command: a p Live ACDC ROCK 70
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Electric Beyonce COUNTRY 30
Performance for band 'Beyonce' added to stage 'Electric'.
Enter command: a p Electric ACDC ROCK 60
Performance for band 'ACDC' added to stage 'Electric'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always ACDC TNT 3.2 7 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Always'.
Enter command: i g Live ACDC Highway_to_hell 4.1 9 1
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Live'.
Enter command: i g Electric ACDC Back_in_Black 3.8 6 1
Song 'Back_in_Black' added to performance for band 'ACDC' on stage 'Electric'.
Enter command: p
Festival: UNSW
==========================================
[Laugh]

00:00 - 01:30 | ACDC (Rock)
  (no songs yet)

==========================================
[Electric]

00:00 - 00:30 | Beyonce (Country)
  (no songs yet)

00:40 - 01:40 | ACDC (Rock)
  1. Back_in_Black (3.8 mins, 6)

==========================================
[Live]

00:00 - 00:40 | Mike (Country)
  (no songs yet)

00:50 - 02:00 | ACDC (Rock)
  1. Highway_to_hell (4.1 mins, 9)

==========================================
[Always]

00:00 - 01:30 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

01:40 - 02:40 | Taylor (Pop)
  (no songs yet)

==========================================
[Forever]

00:00 - 01:20 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: c v ACDC

Conflicts found from 00:00:
------------------------------------------
    - [Forever] 00:00 - 01:20 | ACDC (Rock)
    - [Laugh] 00:00 - 01:30 | ACDC (Rock)
    - [Always] 00:00 - 01:30 | ACDC (Rock)
    - [Electric] 00:40 - 01:40 | ACDC (Rock)
    - [Live] 00:50 - 02:00 | ACDC (Rock)
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a s Electric
a s Cosmic
a p Forever ACDC ROCK 40
a p Always ACDC ROCK 50
a p Live Taylor POP 100
a p Live Mike COUNTRY 30
a p Live ACDC ROCK 40
a p Electric Beyonce COUNTRY 50
a p Electric Slowdive ROCK 60
a p Electric ACDC ROCK 40
a p Cosmic Kiss ROCK 80
a p Cosmic ACDC ROCK 30
p
c v ACDC
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a s Electric
Stage 'Electric' added.
Enter command: a s Cosmic
Stage 'Cosmic' added.
Enter command: a p Forever ACDC ROCK 40
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always ACDC ROCK 50
Performance for band 'ACDC' added to stage 'Always'.
Enter command: a p Live Taylor POP 100
Performance for band 'Taylor' added to stage 'Live'.
Enter command: a p Live Mike COUNTRY 30
Performance for band 'Mike' added to stage 'Live'.
Enter command: a p Live ACDC ROCK 40
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Electric Beyonce COUNTRY 50
Performance for band 'Beyonce' added to stage 'Electric'.
Enter command: a p Electric Slowdive ROCK 60
Performance for band 'Slowdive' added to stage 'Electric'.
Enter command: a p Electric ACDC ROCK 40
Performance for band 'ACDC' added to stage 'Electric'.
Enter command: a p Cosmic Kiss ROCK 80
Performance for band 'Kiss' added to stage 'Cosmic'.
Enter command: a p Cosmic ACDC ROCK 30
Performance for band 'ACDC' added to stage 'Cosmic'.
Enter command: p
Festival: UNSW
==========================================
[Cosmic]

00:00 - 01:20 | Kiss (Rock)
  (no songs yet)

01:30 - 02:00 | ACDC (Rock)
  (no songs yet)

==========================================
[Electric]

00:00 - 00:50 | Beyonce (Country)
  (no songs yet)

01:00 - 02:00 | Slowdive (Rock)
  (no songs yet)

02:10 - 02:50 | ACDC (Rock)
  (no songs yet)

==========================================
[Live]

00:00 - 01:40 | Taylor (Pop)
  (no songs yet)

01:50 - 02:20 | Mike (Country)
  (no songs yet)

02:30 - 03:10 | ACDC (Rock)
  (no songs yet)

==========================================
[Always]

00:00 - 00:50 | ACDC (Rock)
  (no songs yet)

==========================================
[Forever]

00:00 - 00:40 | ACDC (Rock)
  (no songs yet)

Enter command: c v ACDC

Conflicts found from 00:00:
------------------------------------------
    - [Forever] 00:00 - 00:40 | ACDC (Rock)
    - [Always] 00:00 - 00:50 | ACDC (Rock)

Conflicts found from 02:30:
------------------------------------------
    - [Electric] 02:10 - 02:50 | ACDC (Rock)
    - [Live] 02:30 - 03:10 | ACDC (Rock)
Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a p Forever ACDC ROCK 90
a p Forever Taylor POP 60
a p Always Mike COUNTRY 30
a p Always ACDC ROCK 90
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always ACDC TNT 3.2 7 1
p
c v ACDC
c r ACDC
c v ACDC
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a p Forever ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Forever Taylor POP 60
Performance for band 'Taylor' added to stage 'Forever'.
Enter command: a p Always Mike COUNTRY 30
Performance for band 'Mike' added to stage 'Always'.
Enter command: a p Always ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Always'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always ACDC TNT 3.2 7 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Always'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 00:30 | Mike (Country)
  (no songs yet)

00:40 - 02:10 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:40 - 02:40 | Taylor (Pop)
  (no songs yet)

Enter command: c v ACDC

Conflicts found from 00:40:
------------------------------------------
    - [Forever] 00:00 - 01:30 | ACDC (Rock)
    - [Always] 00:40 - 02:10 | ACDC (Rock)
Enter command: c r ACDC
Enter command: c v ACDC
No conflicts found for band 'ACDC'.
Enter command: p
Festival: UNSW
==========================================
[Always]

00:00 - 00:30 | Mike (Country)
  (no songs yet)

00:40 - 01:40 | Taylor (Pop)
  (no songs yet)

01:50 - 03:20 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

==========================================
[Forever]

00:00 - 01:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a p Forever ACDC ROCK 30
a p Always ACDC ROCK 40
a p Live ACDC ROCK 90
a p Forever Taylor POP 50
a p Always Kiss ROCK 20
a p Always Twice ROCK 40
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always ACDC TNT 3.2 7 1
i g Live ACDC Highway_to_hell 4.1 9 1
c v ACDC
p
c r ACDC
c v ACDC
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a p Forever ACDC ROCK 30
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always ACDC ROCK 40
Performance for band 'ACDC' added to stage 'Always'.
Enter command: a p Live ACDC ROCK 90
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Forever Taylor POP 50
Performance for band 'Taylor' added to stage 'Forever'.
Enter command: a p Always Kiss ROCK 20
Performance for band 'Kiss' added to stage 'Always'.
Enter command: a p Always Twice ROCK 40
Performance for band 'Twice' added to stage 'Always'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always ACDC TNT 3.2 7 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Always'.
Enter command: i g Live ACDC Highway_to_hell 4.1 9 1
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Live'.
Enter command: c v ACDC

Conflicts found from 00:00:
------------------------------------------
    - [Forever] 00:00 - 00:30 | ACDC (Rock)
    - [Always] 00:00 - 00:40 | ACDC (Rock)
    - [Live] 00:00 - 01:30 | ACDC (Rock)
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 01:30 | ACDC (Rock)
  1. Highway_to_hell (4.1 mins, 9)

==========================================
[Always]

00:00 - 00:40 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

00:50 - 01:10 | Kiss (Rock)
  (no songs yet)

01:20 - 02:00 | Twice (Rock)
  (no songs yet)

==========================================
[Forever]

00:00 - 00:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

00:40 - 01:30 | Taylor (Pop)
  (no songs yet)

Enter command: c r ACDC
Not all conflicts could be resolved.
Enter command: c v ACDC

Conflicts found from 01:00:
------------------------------------------
    - [Always] 00:50 - 01:30 | ACDC (Rock)
    - [Live] 01:00 - 02:30 | ACDC (Rock)
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 00:50 | Taylor (Pop)
  (no songs yet)

01:00 - 02:30 | ACDC (Rock)
  1. Highway_to_hell (4.1 mins, 9)

==========================================
[Always]

00:00 - 00:40 | Twice (Rock)
  (no songs yet)

00:50 - 01:30 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

01:40 - 02:00 | Kiss (Rock)
  (no songs yet)

==========================================
[Forever]

00:00 - 00:30 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: q
Goodbye!

Input:

UNSW
a s Forever
a s Always
a s Live
a p Forever ACDC ROCK 50
a p Always ACDC ROCK 60
a p Live ACDC ROCK 70
a p Forever Taylor POP 120
a p Always Beyonce COUNTRY 120
a p Live Kiss ROCK 120
i g Forever ACDC Thunderstruck 4.5 8 1
i g Always ACDC TNT 3.2 7 1
i g Live ACDC Highway_to_hell 4.1 9 1
c v ACDC
p
c r ACDC
c v ACDC
p
q

Input and Output:

dcc --leak-check main.c cs_festival.c -o cs_festival
./cs_festival
Welcome to CS Festival!
♪┏(・o・)┛┗ ( ・o・) ┓♪
Enter the name of your festival: UNSW
Enter command: a s Forever
Stage 'Forever' added.
Enter command: a s Always
Stage 'Always' added.
Enter command: a s Live
Stage 'Live' added.
Enter command: a p Forever ACDC ROCK 50
Performance for band 'ACDC' added to stage 'Forever'.
Enter command: a p Always ACDC ROCK 60
Performance for band 'ACDC' added to stage 'Always'.
Enter command: a p Live ACDC ROCK 70
Performance for band 'ACDC' added to stage 'Live'.
Enter command: a p Forever Taylor POP 120
Performance for band 'Taylor' added to stage 'Forever'.
Enter command: a p Always Beyonce COUNTRY 120
Performance for band 'Beyonce' added to stage 'Always'.
Enter command: a p Live Kiss ROCK 120
Performance for band 'Kiss' added to stage 'Live'.
Enter command: i g Forever ACDC Thunderstruck 4.5 8 1
Song 'Thunderstruck' added to performance for band 'ACDC' on stage 'Forever'.
Enter command: i g Always ACDC TNT 3.2 7 1
Song 'TNT' added to performance for band 'ACDC' on stage 'Always'.
Enter command: i g Live ACDC Highway_to_hell 4.1 9 1
Song 'Highway_to_hell' added to performance for band 'ACDC' on stage 'Live'.
Enter command: c v ACDC

Conflicts found from 00:00:
------------------------------------------
    - [Forever] 00:00 - 00:50 | ACDC (Rock)
    - [Always] 00:00 - 01:00 | ACDC (Rock)
    - [Live] 00:00 - 01:10 | ACDC (Rock)
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 01:10 | ACDC (Rock)
  1. Highway_to_hell (4.1 mins, 9)

01:20 - 03:20 | Kiss (Rock)
  (no songs yet)

==========================================
[Always]

00:00 - 01:00 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

01:10 - 03:10 | Beyonce (Country)
  (no songs yet)

==========================================
[Forever]

00:00 - 00:50 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

01:00 - 03:00 | Taylor (Pop)
  (no songs yet)

Enter command: c r ACDC
Enter command: c v ACDC
No conflicts found for band 'ACDC'.
Enter command: p
Festival: UNSW
==========================================
[Live]

00:00 - 02:00 | Beyonce (Country)
  (no songs yet)

02:10 - 04:10 | Taylor (Pop)
  (no songs yet)

04:20 - 05:30 | ACDC (Rock)
  1. Highway_to_hell (4.1 mins, 9)

==========================================
[Always]

00:00 - 02:00 | Kiss (Rock)
  (no songs yet)

02:10 - 03:10 | ACDC (Rock)
  1. TNT (3.2 mins, 7)

==========================================
[Forever]

00:00 - 00:50 | ACDC (Rock)
  1. Thunderstruck (4.5 mins, 8)

Enter command: q
Goodbye!

Clarifications

  • [band_name] is a string with length less than MAX_SIZE and will not contain spaces.
  • You may assume that the resolve conflict command will never result in two performances of the same band being on the same stage, i.e, moving a band's performance from one stage to another stage where the band is already performing.
  • You may assume that performances by the same band will always have the same genre. For example, there will not be a case where ACDC has a ROCK performance conflicting with a COUNTRY performance.
  • This conflict resolution approach uses a single heuristic of shifting performances down to resolve conflicts. It is not guaranteed to resolve all conflicts in every possible scenario. The purpose of this implementation is to follow the specified heuristic consistently, rather than to find an optimal conflict-free schedule. Once you encounter a conflict that cannot be resolved, stop the resolution process and leave the performances in that state.
  • You may assume that a joint performance from stage 4.1 is considered a new performance by a unique band, and will not be considered when finding conflicts for one of the original bands.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_festival.c
1511 style cs_festival.h
1511 style main.c
1511 autotest-stage 04 cs_festival
give cs1511 ass2_cs_festival cs_festival.c cs_festival.h main.c

Extension

As an extension, we have set up a starting point to add a texture pack to your program via SplashKit.

Extension activities are NOT worth any marks, nor are there any autotests. They are just for fun!

Getting Started

To get started with SplashKit, complete the SplashKit activities.

Sample Code

First, navigate to your SplashKit directory.

cd splashkit

Create a new directory for your project and cd into it.

mkdir cs_festival
cd cs_festival

Set up your directory for SplashKit with:

1511 setup-splashkit-directory

Run this cp command to retrieve the sample code.

cp -n /web/cs1511/25T3/activities/cs_festival/splashkit_example.c .

This should add the splashkit_example.c sample code to your current directory.

Check that SplashKit Works

Let's check that SplashKit works by running a test file. It should display a white square with a grid inside.

skm clang++ splashkit_example.c -o splashkit_example
./splashkit_example

Have a look inside of splashkit_example.c and note that:

  • At the very top, the the SplashKit library "splashkit.h" is included. If you see an error here, check SplashKit #1 - Getting Started for a solution to set up your VS Code project.
  • In the main() function:
    • open_window("SplashKit Example", 600, 400) creates a 600×400 window for displaying graphics.
    • The while (!window_close_requested(w)) loop keeps running until the user closes the window. Within this loop:
      • process_events() handles input or window-related actions (like closing the window).
      • refresh_screen() updates the window so any graphical changes (like drawing a rectangle) are displayed to the user.

Running Your SplashKit Code

When creating your SplashKit program, give it a distinctive name like splashkit_cs_festival.c.

To compile and run your program, use:

skm clang++ splashkit_cs_festival.c -o splashkit_cs_festival
./splashkit_cs_festival

Writing Your SplashKit Program

Now that you've seen how the sample code works, it’s time to create your own SplashKit program.

If you're not sure where to begin, start by researching the SplashKit Library. The goal at first is not to understand and memorise the entire library. Rather, it's better to skim through the pages to build a broad understanding of the capabilities that SplashKit can bring to your creations.

The Graphics page is a good place to start, and the following sections will be useful:

  • Windows for opening, closing, and controlling the size of windows.
  • Color for using different colours.
  • Graphics for drawing shapes, images, and text.
  • Geometry for handling shapes such as rectangles, circles, lines, and points.
  • Input for capturing and handling user input such as keyboard and mouse events.

SplashKit Gallery

Have you built something fun or interesting using SplashKit? Show it off and inspire your classmates!

Share any screenshots or short videos of your running program in the SplashKit Gallery on the Course Forum. Feel free to add a brief description or reflect on how you made it, so we can all learn from your mistakes journey 😅.

Tools

Creating Festivals in Separate Files

If you are getting sick of typing your inputs every time you run CS Festival, you might want to store your input in a separate file.

1. Create a file for your input.

First, let's create a file to store in the input for a festival that you have created. This isn't a .c file, it's just a regular plain text file, the file extension .in works nicely for this!

Let's put it in the same directory as your assignment code.

cd ass2
ls
cs_festival.c 
cs_festival.h
main.c
cs_festival
my_festival.in

2. Add your input to the file

Inside of this file, add the input for the festival.

Your file could look a bit like this (including the newline at the end):

UNSW
a s Forever
a p Forever ACDC ROCK 90
p
q

3. Run the code with your file

Next, instead of just running ./cs_festival, lets tell the computer to first read from the file we created.

cat my_festival.in - | ./cs_festival

This will also work on the reference implementation too!

cat my_festival.in - | 1511 cs_festival




Assessment

Assignment Conditions

  • Joint work is not permitted on this assignment.

    This is an individual assignment.

    The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted.

    The only exception being if you use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publicly available resources. You should attribute the source of this code clearly in an accompanying comment.

    Assignment submissions will be examined, both automatically and manually for work written by others.

    Do not request help from anyone other than the teaching staff of COMP1511.

    Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently autotested or submitted with give.

    Rationale: this assignment is an individual piece of work. It is designed to develop the skills needed to produce an entire working program. Using code written by or taken from other people will stop you learning these skills.

  • The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment.

    The use of Generative AI to generate code solutions is not permitted on this assignment.

    Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts.

  • Sharing, publishing, distributing your assignment work is not permitted.

    Do not provide or show your assignment work to any other person, other than the teaching staff of COMP1511. For example, do not share your work with friends.

    Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository.

    Rationale: by publishing or sharing your work you are facilitating other students to use your work, which is not permitted. If they submit your work, you may become involved in an academic integrity investigation.

  • Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted.

    For example, do not place your assignment in a public GitHub repository after COMP1511 is over.

    Rationale:COMP1511 sometimes reuses assignment themes, using similar concepts and content. If students in future terms can find your code and use it, which is not permitted, you may become involved in an academic integrity investigation.

Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in COMP1511 and exclusion from UNSW.

Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted - you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you.

If you have not shared your assignment, you will not be penalised if your work is taken without your consent or knowledge.

For more information, read the UNSW Student Code , or contact the course account. The following penalties apply to your total mark for plagiarism:

0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.

Submission of Work

You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You can find those backups  here , by logging in, and choosing the yellow button next to ass2_cs_festival.

Every time you work on the assignment and make some progress, you should copy your work to your CSE account and submit it using the give  command below.

It is fine if intermediate versions do not compile or otherwise fail submission tests.

Only the final submitted version of your assignment will be marked.

You submit your work like this:

  give cs1511 ass2_cs_festival cs_festival.c cs_festival.h main.c

Assessment Scheme

This assignment will contribute 25% to your final mark.

80% of the marks for this assignment will be based on the performance of the code you write in cs_festival.c cs_festival.h main.c.

20% of the marks for this assignment will come from manual marking of the readability of the C you have written. The manual marking will involve checking your code for clarity, and readability, which includes the use of functions and efficient use of loops and if statements.

Marks for your performance will be allocated roughly according to the below scheme.

COMP1911

100% for Performance Completely Working Implementation, which exactly follows the specification (Stage 1, 2 and 3.3).
85% for Performance Completely Working implementation of Stage 1 and Stage 2.
40% for Performance Completely Working implementation of Stage 1.

COMP1511

100% for Performance Completely Working Implementation, which exactly follows the specification (Stage 1, 2, 3 and 4).
85% for Performance Completely working implementation of Stage 1, 2 and 3.
65% for Performance Completely working implementation of Stage 1 and Stage 2.
35% for Performance Completely working implementation of Stage 1.

Marks for your style will be allocated roughly according to the scheme below.

Style Marking Rubric

0 1 2 3 4
Formatting (/5)
Indentation (/2) - Should use a consistent indentation scheme. Multiple instances throughout code of inconsistent/bad indentation Code is mostly correctly indented Code is consistently indented throughout the program
Whitespace (/1) - Should use consistent whitespace (for example, 3 + 3 not 3+ 3) Many whitespace errors No whitespace errors
Vertical Whitespace (/1) - Should use consistent whitespace (for example, vertical whitespace between sections of code) Code has no consideration for use of vertical whitespace Code consistently uses reasonable vertical whitespace
Line Length (/1) - Lines should be max. 80 characters long Many lines over 80 characters No lines over 80 characters
Documentation (/5)
Comments (incl. header comment) (/3) - Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included No comments provided throughout code Few comments provided throughout code Comments are provided as needed, but some details or explanations may be missing causing the code to be difficult to follow Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included
Function/variable/constant naming (/2) - Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code Functions/variables/constants names do not follow naming conventions in style guide and help in understanding the code Functions/variables/constants names somewhat follow naming conventions in style guide and help in understanding the code Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code
Organisation (/5)
Function Usage (/4) - Code has been decomposed into appropriate functions separating functionalities No functions are present, code is one main function Some code has been moved to functions Some code has been moved to sensible/thought out functions, and/or many functions exceed 50 lines (incl. main function) Most code has been moved to sensible/thought out functions, and/or some functions exceed 50 lines (incl. main function) All code has been meaningfully decomposed into functions of a maximum of 50 lines (incl. The main function)
Function Prototypes (/1) - Function Prototypes have been used to declare functions above main Functions are used but have not been prototyped All functions have a prototype above the main function or no functions are used
Elegance (/5)
Overdeep nesting (/2) - You should not have too many levels of nesting in your code (nesting which is 5 or more levels deep) Many instances of overdeep nesting <= 3 instances of overdeep nesting No instances of overdeep nesting
Code Repetition (/2) - Potential repetition of code has been dealt with via the use of functions or loops Many instances of repeated code sections <= 3 instances of repeated code sections Potential repetition of code has been dealt with via the use of functions or loops
Constant Usage (/1) - Any magic numbers are #defined None of the constants used throughout program are #defined All constants used are #defined and are used consistently in the code
Illegal elements
Illegal elements - Presence of any illegal elements indicated in the style guide CAP MARK AT 16/20

Note that the following penalties apply to your total mark for plagiarism:

0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.

Allowed C Features

This assignment must be implemented exclusively using linked lists for all core data structures and logic. Other than arrays, there are no restrictions on C features in this assignment, except for those outlined in the Style Guide. If you choose to use features beyond what has been taught in COMP1511/1911, be aware that course staff may not be able to assist you.

Due Date

This assignment is due 21 November 2025 17:00:00. For each day after that time, the maximum mark it can achieve will be reduced by 5% (off the ceiling).
  • For instance, at 1 day past the due date, the maximum mark you can get is 95%.
  • For instance, at 3 days past the due date, the maximum mark you can get is 85%.
  • For instance, at 5 days past the due date, the maximum mark you can get is 75%.
No submissions will be accepted after 5 days late, unless you have special provisions in place.

Change Log

Version 1.0
(2025-10-30 09:00)
  • Assignment Released
Version 1.1
(2025-10-30 16:00)
  • Updated diagrams for stages 01_01, 04_01_join_before, 04_01_merge_setlist_before
Version 1.2
(2025-10-30 18:00)
  • Stage 4.2: corrected example traversal order explanation not matching diagram
Version 1.3
(2025-10-30 20:00)
  • Correct example 1.2.2 output.
Version 1.4
(2025-10-31 23:00)
  • Stage 1.4: Correct example output for main function test
Version 1.5
(2025-11-02 15:00)
  • Stage 4.2: Fix priority for shifted performance
Version 1.6
(2025-11-10 10:00)
  • Stage 4.1: Add clarification for joining performance with itself + Stage 4.2: Fix order priority for resolving conflicts + command argument assumptions
Version 1.7
(2025-11-20 22:00)
  • Stage 4.1: Remove autotest 04_01_05 due to typo