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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
void addBook()
{
//Search addbook array for null terminator
int bookResult = searchList();
//If searchList returned -1, then array was full
if (bookResult == -1)
cout << "No more books may be added to the inventory." << endl;
else
{
//Otherwise results contain an empty row
cin.getline(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "Please enter the Book Title " << endl;
cin.getline(&bookTitle[bookResult][0],TITLE_LENGTH);
cout << "Please enter the ISBN number " << endl;
cin.getline(&isbn[bookResult][0],ISBN_LENGTH);
cout << "Please enter the Author's name " << endl;
cin.getline(&author[bookResult][0],AUTHOR,LENGTH);
cout << "Please enter the Publisher's name " << endl;
cin.getline(&publisher[bookResult][0],PUB_LENGTH);
cout << "Please enter the date the book is added to the ";
cout << "inventory " << endl;
cin.getline(&dateAdded[bookResult][0],DATE_LENGTH);
cout << "Please enter the quanity of the book " << endl;
cin >> qtyOnHand[bookResult];
cout << "Please enter the wholesale price of the book " << endl;
cin >> wholesale[bookResult];
cout << "Please enter the retail price of the book " << endl;
cin >> retail[bookResult];
}
}
void editBook()
{
char titleResults;
//Function Prototype
char binarySearch(char [], char, char);
const char SIZE = 51;
//Get the title of the book to search for
cout << "Enter the title of the book you wish to search for. " << endl;
cin >> titleBook;
//Search for the title of the book
titleResults = binarySearch(bookTitle, SIZE, titleBook);
//If titleResults contain -1 the book was not found.
if (titleResults == -1)
cout << "That book was not found." << endl;
else
//Otherwise titleResults contains the searched book
return int bookInfo;
}
void deleteBook()
{
cout << "You selected Delete Book." << endl;
}
//This function is to display the book info screen
int bookInfo()
{
cout << endl;
cout << "Serendipity Booksellers" << endl;
cout << "Book Information " << endl;
cout << " " << endl
cout << "ISBN: " << endl;
//DisplayTheArray(isbn);
cout << "Title: " << endl;
//DisplayTheArray(bookTitle);
cout << "Author: " << endl;
//DisplayTheArray(author);
cout << "Publisher: " << endl;
//DisplayTheArray(publisher);
cout << "Date Added: " << endl;
//DisplayTheArray(dateAdded);
cout << "Quantity-On-Hand: " << endl;
//DisplayTheArray(qtyOnHand);
cout << "Wholesale Cost: " << endl;
//DisplayTheArray(wholesale);
cout << "Retail Price: " << endl;
//DisplayTheArray(retail);
return 0;
}
//This function is to display the reports screen
int reports()
{
int choice; //Menu choice
do
{
//Display the menu and get a choice
cout << endl;
cout << "Serendipity Booksellers" << endl;
cout << "Reports " << endl;
cout << "1. Inventory Listing " << endl;
cout << "2. Inventory Wholesale Value " << endl;
cout << "3. Inventory Retail Value " << endl;
cout << "4. Listing by Quantity " << endl;
cout << "5. Listing by Cost " << endl;
cout << "6. Listing by Age " << endl;
cout << "7. Return to the Main Menu " << endl;
cout << " " << endl;
cout << "Enter your choice: " << endl;
cin >> choice;
switch (choice)
{
case 1: void repListing();
break;
case 2: void repWholesale();
break;
case 3: void repRetail();
break;
case 4: void repQty();
break;
case 5: void repCost();
break;
case 6: void repAge();
break;
case 7: cout << "You selected item 7." << endl;
break;
}
//Validate and process the menu choice.
while (choice < 1 || choice > 7)
{
cout << "Please enter a number in the range 1-7." << endl;
cin >> choice;
}
} while (choice != 7);
return 0;
}
//Add stub functions for reports menu
void repListing()
{
cout << "You selected Inventory Listing." << endl;
}
void repWholesale()
{
cout << "You selected Inventory Wholesale Value." << endl;
}
void repRetail()
{
cout << "You selected Inventory Retail Value." << endl;
}
void repQty()
{
cout << "You selected Listing By Quantity." << endl;
}
void repCost()
{
cout << "You selected Listing By Cost." << endl;
}
void repAge()
{
cout << "You selected Listing By Age." << endl;
}
//*********************************************************
//This function is to search the bookTitle for an empty row
//*********************************************************
int searchList()
{
int index = 0;
int position = -1;
while (index < MAX_ENTRIES)
{
if (bookTitle[index][0] == [0])
{
position = index;
}
index++;
}
return position;
}
//**********************************************************
//This function is to search the bookTitle array for a value
//**********************************************************
int binarySearch()
{
char first = A,
char last = numelems - 1,
char middle,
char position = -1;
book found = false;
while (!found && first <= last)
{
middle = (first + last) / 2;
if (array[middle] == value)
{
found = true;
position = middle;
}
else if (array[middle] > value)
last = middle -1;
else
first = middle +1;
}
return position;
}
| |