Bag  0.91
Functions
BagDriver.cpp File Reference
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "ArrayBag.h"
#include "io_functions.h"

Go to the source code of this file.

Functions

int getBagNum ()
void processOption (char &c, ArrayBag< string > bags[])
void displayBag (ArrayBag< string > &bag)
void restoreBag (ArrayBag< string > &bag)
void saveBag (ArrayBag< string > &bag)
int main ()

Detailed Description

Bag Driver - use to test Bag class methods and functions that are independent from the Bag class. Bags 1 & 2 are used troughout, bag 0 is extra for testing

Author
Jeff Braun
Version
0.91
Date
8/30/16

Definition in file BagDriver.cpp.

Function Documentation

void displayBag ( ArrayBag< string > &  bag)

Displays the entire content of the bag

Parameters
[in]bagto display
Remarks
If bag is empty, prints empty bag message.

Definition at line 101 of file BagDriver.cpp.

References ArrayBag< ItemType >::toVector().

Referenced by processOption().

int getBagNum ( )

Reads, validates, and returns a 1 or 2

Precondition
none
Postcondition
none
Returns
1 or 2

Definition at line 85 of file BagDriver.cpp.

References getInt().

Referenced by main(), and processOption().

int main ( )

Bag Driver - use to test Bag class methods and bag functions that are independent from the Bag class.

Definition at line 42 of file BagDriver.cpp.

References getBagNum(), printMenu(), processOption(), and restoreBag().

void processOption ( char &  menuChar,
ArrayBag< string >  bag[] 
)

Process input menu option character from user.

Parameters
[in]menuCharmenu option character
[in,out]bagthe bag to be modified

Definition at line 126 of file BagDriver.cpp.

References displayBag(), getBagNum(), ArrayBag< ItemType >::getCurrentSize(), getItem(), printMenu(), and saveBag().

Referenced by main().

void restoreBag ( ArrayBag< string > &  bag)

Restore the bag from a user specified file

Parameters
[in,out]bagrestored from input file
Postcondition
The bag contains all items in the file if size < max bag list.
Remarks
Prompt the user for the filename to retore the bag from. If cannot open file, then reprompt user for filename. Read items from file until end of file (eof) reached or until the bag is full. Print the number of items read from the file.

Definition at line 188 of file BagDriver.cpp.

References ArrayBag< ItemType >::add(), and ArrayBag< ItemType >::getCurrentSize().

Referenced by main().

void saveBag ( ArrayBag< string > &  bag)

Prompts the user for the filename to store the bag in.

Parameters
[in]bagto be saved to a user specified file

Definition at line 219 of file BagDriver.cpp.

Referenced by processOption().