#include <stdio.h> // Include stdio.h for basic functions
#include <string.h> // Include string.h for string manipulation

#include "Artist.h" // Include Artist.h for related structs and function prototypes

Artist InitArtist() { // Function to initialize variables in Artist struct to default, used only in unit tests
    Artist artist; // Create local artist struct variable
    strcpy(artist.name, "None"); // Copy "None" to name in artist struct
    artist.birthYear = 0; // Set birthYear in artist struct to 0
    artist.deathYear = 0; // Set deathYear in artist struct to 0
    return artist; // Return artist struct variable
}

Artist SetArtist(char* name, int birthYear, int deathYear) { // Function to set variables in artist struct to user input
    Artist artist; // Create local artist struct variable
    strcpy(artist.name, name); // Copy user input name to name in artist struct
    artist.birthYear = birthYear; // Set birthYear in artist struct to user input birthYear
    artist.deathYear = deathYear; // Set deathYear in artist struct to user input deathYear
    return artist; // Return artist struct variable
}

void GetName(char* name, Artist artist) { // Function to return name of artist, used only in unit tests
    strcpy(name, artist.name); // Copy user input name to name in artist struct
}

int GetBirthYear(Artist artist) { // Function to return birthYear of artist, used only in unit tests
    return artist.birthYear; // Return birthYear in artist struct
}

int GetDeathYear(Artist artist) { // Function to return deathYear of artist, used only in unit tests
    return artist.deathYear; // Return deathYear in artist struct
}

void PrintArtist(Artist artist) { // Function to print artist information
    if (artist.deathYear < artist.birthYear) { // If deathYear is not greater than or equal to birthYear (indicates artist is not dead)
        printf("Artist: %s, born %d\n", artist.name, artist.birthYear); // Print artist information (minus deathYear)
    } else { // If deathYear is greater than or equal to birthYear (artist is dead)
        printf("Artist: %s (%d-%d)\n", artist.name, artist.birthYear, artist.deathYear); // Print artist information
    }
}