So guys, first post and these forums have been very helpful in helping me understand programming a little better. Problem is that I really don't know what I'm doing and I need help and time is running out (as of writing I have 4 days to write it all).
Here are the specifications:
Write a C++ class called Song to represent a song in a music collection. The data members of the Song class are strings representing the song title, artist’s name, and the album where the song can be found. These instance variables for the class are to have private access modifiers so I need to write the appropriate functions to allow a client to access and modify the data values. In addition, I need to write an overloaded equality (==) function; two songs are equal if they have the same title, artist, and album, regardless of the case of the letters. I also need to implement an overloaded greater-than (>) function because I will be using this program throughout the semester.
A second file is to be written called SongList that contains a main function and separate function to display a menu of options for the user. The menu will contain options that allow the user to:
1. Add a song
2. Remove a song
3. Display all the songs in the list
4. Quit
I have to store the Song objects in an array with a size of 10.
Songs are to be compared lexicographically (first by album and then by song) when implementing the overloaded greater-than function.
The format of the output when the user selects menu option 3. (Display all the songs in the list) should look like this:
Title: Song Title
Artist: Artist name
Album: Album name
So, I've gotten a functional menu working and I have a really good idea of what I'm supposed to be doing but I just don't know how to write it at all.
Included are the lines of code I've already written.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
/**Chimuel*/
/**Project 01*/
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdlib>
#include "Song.h"
using namespace std;
int option;
int menu();
int counter = 0;
Song collection[10];
/**This initilizes a fnction that prints a header.*/
void printHeading(int h)
{
printf("\n\nChimuel \nCMSC - Project 0%d", h);
}
/**Functions for the program*/
void Addsong(int counter)
{
string ttl;
string art;
string alb;
cout << "\nEnter song title:" << endl;
getline(cin, ttl); getline(cin, ttl);
collection[counter].setTitle(ttl);
cout << "\nEnter song artist:" << endl;
getline(cin, art);
collection[counter].setArtist(art);
cout << "\nEnter song album:" << endl;
getline(cin, alb);
collection[counter].setAlbum(alb);
menu();
}
/**Song::Song(string title, string artist, string album)
{
ttl = title;
art = artist;
alb = album;
}*/
void Song::setTitle(string title)
{
}
void Song::setArtist(string artist)
{
}
void Song::setAlbum(string album)
{
}
void Remove()
{
cout << "\nPick which song you want to remove:" << endl;
menu();
}
void Display()
{
/**
int loco;
Song list;
cout << "\nHere are the songs in your collection:\n\n" << endl;
for(loco = 0; loco < 10; loco++);
{
list = collection[loco];
if(loco + 1 < 10)
{
cout << " " << loco + 1 << " | ";
}
else
cout << loco + 1 << " | ";
}
cout << list.getTitle() <<
cout << list.getArtist() <<
cout << list.getAlbum() <<
cout << endl;
*/
cout << "\nHere are the songs in your collection:" << endl;
cout << "Title:" << endl;
cout << "Artist:" << endl;
cout << "Album:" << endl;
menu();
}
void Exit()
{
cout << "\nBye!\n\n" << endl;
}
int main()
{
/**Prints the heading*/
printHeading(1);
menu();
}
int menu()
{
/** Displaying the menu */
cout << "\n\n\nWhat do you want to do?\n" << endl;
cout << "\n1. Add a song" << endl;
cout << "\n2. Remove a song" << endl;
cout << "\n3. Display all the songs in the list" << endl;
cout << "\n4. Quit\n" << endl;
/** Getting input */
cin >> option;
/** Selecting case and calling functions associated */
switch (option) {
case 1:
cout << "\nAdd a song" << endl;
Addsong(counter);
counter++;
break;
case 2:
cout << "\nRemove a song" << endl;
Remove();
break;
case 3:
cout << "\nDisplay a song" << endl;
Display();
break;
case 4:
Exit();
break;
default:
cout << "\nInput a value between 1-4" << endl;
return menu();
}
return 0;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
/** Song.h */
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
class Song
{
public:
//Song();
//Song(string title, string artist, string album);
string getTitle();
string getArtist();
string getAlbum();
void setTitle(string title);
void setArtist(string artist);
void setAlbum(string album);
private:
string ttl;
string art;
string alb;
};
|
Thank you for even reading through this, I really appreciate it.