Homework 7, The Musical Artist Class.
Short Description:
Create a class to store musical artists.
This assignment is worth 10 points.
Goals
When you finish this homework, you should have:
- Create and test a class that stores musical artists.
Formal Description
For our next project we will be creating a simple database to store songs and the artists that performed those songs. We will implement a system where the either the song or the artist can be upvoted or downvoted.
In preparation for this you will be implementing and testing an artist class.
- Begin by creating a directory to hold this homework.
- The ArtistT class
- The domain
- The artist name, a string.
- The artist ID, an integer
- This is for use in the larger system.
- It will be set to -1 initially
- It can only be assigned one time.
- The number of up votes an artist has received.
- The number of down votes an artist has received.
- An array of song ids the artist has performed.
- This will be limited to MAX_SONGS_PER_ARTIST
- The number of songs an artist has performed.
- The operations
- A constructor to create an empty artist.
- A getter and setter for the name.
- A getter and setter for the id.
- A getter for the up and down votes
- A Setter for up and down votes.
- A getter for the number of songs
- A setter to add an id to the song list
- A getter for a song id
- The UML diagram
- Implement the header file.
- Edit ArtistT.h
- Include
#pragma once
at the top
- We will need string so include the string library
- We will nee ProgramConstants.h so include that as well
- Remember to use quotes and not angle brackets.
-
- Declare the class ArtistT
- Add the public and private declarations.
- Please put public first.
-
- Add the member data to the private area
- Use the types and the identifiers specified in the UML diagram above.
-
- Add the member functions to the public area
- Use the above UML diagram.
-
- Add a function prototype for
PrintArtist
- This should take a const reference to an artist.
-
- Implement the class
- In the file
ArtistT.cpp
- The constructor
- Set songCount, upVotes and downVotes to 0.
- Set ArtistID to -1
- In the observers, return the value requested.
- In the ID setter
- Set the id only if the current id is -1 and the new id is not negative.
- In UpVote and DownVote
- increment the appropriate member data variable by 1.
- In
AddSongID
- If there is space left in the array,
- Add the id to the end of the song list.
- Increment the songCount variable
- return true
- Otherwise
- Print the following error message
- return false
- For
SongID
- If the supplied index is in range, return the corresponding id.
- Otherwise return -1
- All other getters should return the appropriate value.
- Implement the PrintArtist function
- Print Artist Name: followed by the artist name and a newline.
- Print a tab, Song Count: followed by the song count and a newline
- Print a tab, Total Up Votes: followed by the upvotes and a newlone
- Print a tab, Total Down Votes: followed by the down votes and a newline.
- If there are any song ID registered:
- Print a tab
- Print Song IDs for songs by
- Print the artists name, followed by a colon.
- Print a comma separated list of the song is.
- Example:
- Build you own test program called
myArtistTest.cpp
- Check to make sure the default constructor works properly.
- Check to make sure the ID setter functions properly
- Try to set the id to a positive number twice
- Try to set the id to a negative number
- Check to make sure you can not insert too many song ids
- You can not check the error message programatically
- But you can check the return value.
- Check to make sure you can not retrieve a song id with a bad index(too high or negative)
- Modify the Makefile
- Modify the objects to compile
-
Required Files
A single tar file containing the source code and makefile for this program.
If you need to communicate any further information, please include this in a text file called ReadMe in this directory.
Please do not include executables in the tar file.
Submission
Submit the tar file to the d2l folder Homework 7 by the due date.