📄 bakery.cpp
字号:
// Exercise 16.12: Bakery.cpp
// Enables users to add customers to, remove customers from,
// a shopping list.
#include <iostream> // required to perform C++-style stream I/O
#include <iomanip> // required for parameterized stream manipulators
using namespace std; // for accessing C++ Standard Library members
#include "Customer.h" // Customer class definition
#include "List.h" // List class definition
int displayMenu(); // function prototype
// function main begins program execution
int main()
{
int selection = 0; // stores the user's menu selection
string customerName; // stores the customer name
while ( selection != 3 )
{
selection = displayMenu();
switch ( selection )
{
// enter customer information
case 1:
cin.ignore(); // remove newline from cin
// prompt user for and input customer name
cout << "\nEnter customer name: ";
getline( cin, customerName ); // get name
// create new Customer, using zero pointer for next
// customer because it is added at the end of the list
break;
// remove a customer
case 2:
// search for the customer and remove it if found
break;
// exit
case 3: // take no action because while loop will terminate
cout << "\n"; // insert newline for readability
break;
default:
cout << "Error: Enter a valid menu selection";
} // end switch
} // end while
return 0; // indicate that program ended successfully
} // end function main
// displays a menu and returns the selected menu option number
int displayMenu()
{
int selection = 0; // stores the menu option number
// display the menu
cout << "\nSelect one of the following options" << endl;
cout << "1 - Add name to list" << endl;
cout << "2 - Get next customer" << endl;
cout << "3 - Exit the application" << endl;
cout << "Enter selection: ";
cin >> selection;
return selection; // return the selection
} // end function displayMenu
/**************************************************************************
* (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -