Created
April 29, 2013 08:23
-
-
Save danamuise/3949a3680c6aee560863 to your computer and use it in GitHub Desktop.
COMP130 Term Project 4/29/2013
Function header file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************* HEADER FILE ******************************************************** | |
File: EndangeredSpecies_H.h | |
Name: Dana Muise | |
Date: 4/29/2013 | |
Purpose: Function construtors for Endagered Species application | |
The Endangered Species Application opens a text file named "animals.txt" and displays the a list of endagered animals. | |
Three attributes are displayed: Name, population and species. The following actions are possible: | |
-Display the list | |
-Modify selected attributes of list members | |
-Add new items to the list | |
-Delete items on the list | |
-Ensure all items begin with capital letters | |
-Delete duplicate entries, while consolidating the data | |
-Save changes to the list, overwriting original text file. | |
endangeredSpecies(); | |
This the primary function of the Endangered Species application. | |
All other functions are call from within this function. | |
The function creates a struct Array named animals[] with 3 paramters: Name, Population & Species. | |
int mainMenu (Endangered animals[], int &stringLength) | |
This function creates the main menu for the application. From here, the user is prompted to select from a veriety of tasks related to the list. | |
Preconditions: struct array animals[] is passed. int stringLength variable is passed by refernce, assumed to be valid. | |
Postcondition: returns an int=1, quitting the eapplication if the user selects Quit from the menu. | |
int readFile(Endangered animals[], int &stringLength) | |
This function reads the data from an external file and populates the array animals[]. | |
Preconditions: A text file named "animals.txt" must be located in the same directory as the driver.cpp file. The delimiter # must be used. | |
struct array animals[] is passed. int stringLength variable is passed by reference, assumed to be valid. | |
Postcondition: returns an int=1, quitting the eapplication if the file cannot be opened. | |
void displayList(Endangered animals[], int stringLength) | |
This function displays the list from the array animals[] | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
void displayMostEndangered(Endangered animals[], int stringLength); | |
This function will display an amount of most endangered animals. The user is prompted to enter the number and species of aniamls to display. | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
void addEntry(Endangered animals[], int &stringLength); | |
This function allows the user to add an entry to the list. | |
Preconditions: struct array animals[] is passed. int stringLength variable is passed by refernce, assumed to be valid. | |
void bubbleSort (Endangered tempArray[], int counter); | |
This function sorts the list alphabetically. | |
Preconditions: struct array tempArray[] and int counter variable are passed, assumed to be valid. | |
void caseFix (Endangered animals[], int stringLength); | |
This function runs through each name in the animals[] array and ensures that only the first letter is capitalized. | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
void consolidate (Endangered animals[], int &stringLength) | |
This function checks for duplicate entries. If found, the populations are added and the extra entry is deleted. | |
Preconditions: struct array animals[] is passed. int stringLength variable is passed by refernce, assumed to be valid. | |
void editEntry (Endangered animals[], int stringLength); | |
This function allows the user to edit the existing memebers of the current list. | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
int saveOut (Endangered animals[], int stringLength); | |
If the user quits, this function will present the option to write the current array animal[] to a text file "animal.txt", overwriting the original. | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
Postcondition: returns an int=1, quitting the application if the file cannot be opened. | |
void deleteEntry(Endangered animals[], int &stringLength); | |
This function allows the user to delete any selected item in the array animal[], and updates the list. | |
Preconditions: struct array animals[] is passed. int stringLength variable is passed by refernce, assumed to be valid. | |
void miniMenu(Endangered animals[], int stringLength); | |
This function prompts the user to type "M" to return to the main menu | |
Precondition: struct array animals[] and int stringLength variable is passed, assumed to be valid. | |
int getAndCheckInt(); | |
This function determines if the user entered an integer | |
Postcondition: an integer is returned assuming the input is valid. | |
bool againYN(); | |
This function determines if the user entered a valid Y or N repsonse | |
Postcondition: A boolean value is returned assuming the input is valid. | |
void editSpecies(Endangered animals[], int edit); | |
This function allows the user to edit a specific species in the array animals[] | |
Precondition: struct array animals[] and int edit variable is passed, assumed to be valid. | |
void splashPage(); | |
This function displays the title of the application after it is launched. | |
*/ | |
#include <iostream> | |
#include <ctype.h> | |
#include<string> | |
#include <fstream> | |
#include <iomanip> | |
#include "conio.h" | |
#include <limits> | |
#include <sstream> | |
using namespace std; | |
namespace danaMuise | |
{ | |
struct Endangered | |
{ | |
string name; | |
int population; | |
char species; | |
}; | |
void endangeredSpecies(); | |
int mainMenu (Endangered animals[], int &stringLength); | |
int readFile(Endangered animals[], int &stringLength); | |
void displayList(Endangered animals[], int stringLength); | |
void displayMostEndangered(Endangered animals[], int stringLength); | |
void addEntry(Endangered animals[], int &stringLength); | |
void bubbleSort (Endangered tempArray[], int counter); | |
void caseFix (Endangered animals[], int stringLength); | |
void consolidate (Endangered animals[], int &stringLength); | |
void editEntry (Endangered animals[], int stringLength); | |
int saveOut (Endangered animals[], int stringLength); | |
void deleteEntry(Endangered animals[], int &stringLength); | |
void miniMenu(Endangered animals[], int stringLength); | |
int getAndCheckInt(); | |
bool againYN(); | |
void editSpecies(Endangered animals[], int edit); | |
void splashPage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment