http://cs.txstate.edu/~rp44/cs2308_152/Assignments/TsuPod1/tsuPod.html header fi
ID: 641300 • Letter: H
Question
http://cs.txstate.edu/~rp44/cs2308_152/Assignments/TsuPod1/tsuPod.html
header file link:
http://cs.txstate.edu/~rp44/cs2308_152/Assignments/TsuPod1/tsuPod.h
tsuPod
CS 2308
For this program we will be implementing the storage portion of the tsuPod (pronounced "su Pod" - the much smaller version of the iPod). We will be storing the following information:
Up to 8 songs not to exceed 25MB
For each song we will store the title (string), artist (string), and size (int) in MB
the title and artist cannot be blank
the size must be greater than zero
Funtionality
(You will be graded on the following functions and the test plan)
the header file that you will use
NOTE: The structure for holding the data will be global to the tsuPod.cpp module. We will discuss the trades-off regarding this in class.
const int NUM_SONGS = 8; //we will have 8 slots. some may be empty (signified with empty strings)
const int MEMORY_SIZE = 25; //size in MB
//Note: The data structure for this module is global to the tsuPod.cpp module, but hidden
//from the user of the module.
//We will see that this style is more similar to OOP and
//hides the implementation details from the user.
Song songs[NUM_SONGS]; //NUM_SONGS is defined in the tsuPod file
Things you should do:
Use an array of structures
Can be initialized with empty songs in advance.
Use constants (global is fine) for the number of songs and the memory size in case we can afford more memory later.
Create a function that returns the total amount of remaining memory (or used memory, up to you).
Test plan:
Create a plan to test the above functionality.
The test plan may include the code for a driver program and possibly an input file should you choose to use one (I would).
You can come up with whatever format you want for that input file.
Don't include any testing functionality in the functions listed above.
The plan should test for all the various error conditions, e.g.
too many songs
using too much memory
deleting a song that is there
deleting a song that isn't there
successfully adding a song
etc.
Example Test Plan Items
Example Driver Program
NOTES:
You may do this program as an individual or with one partner. If you use a partner, you will use the pair programming techniques we discuss in class.
This program does not have to be done in a Unix environment. You may use whatever C++ programming environment ( Eclipse, Visual C++, Dev-C++, etc) you prefer.
The program must be modular, with significant work done by functions. Each function should perform a single, well-defined task. When possible, create re-usable functions. Do not write trivial functions such as a function to read a single value from an input file.
You must place appropriate functions in a library (the header .h file will be provided)
example files (create a project and put these in to test)
Explanation / Answer
#include
#include
#include
using namespace std;
const int NUM_SONGS = 8;
const int MEMORY_SIZE = 25; //size in MB
struct songs
{
string titles[NUM_SONGS];
string artists[NUM_SONGS];
int sizes[NUM_SONGS];
};
Songs ss;
Void Tsu::initTsupod(void)
{
For (int i=0;i
{curr=0;
ss.titles[i]=
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.