Example #1
0
int main(){
	Mall mall;

	mall.addStore("book","first book store");
	mall.addStore("game","first game store");
	mall.addStore("shoe","first shoe store");

   BookStore* secondbook=new BookStore("second book store");
   Book* book=secondbook->orderBook("novel");

   ShoeStore secondshoe("second shoe store");
   GameStore secondgame("second game store");

   mall.printStores();

   Customer* customer1=new Customer("Tugce");
   Customer* customer2=new Customer("Ahmet");
   Customer* customer3=new Customer("Asli");

   Book* book1=new Book();
   Shoe* shoe1=new Shoe();
   Game* game1=new Game();

   secondbook->addItem(book1);
   secondshoe.addItem(shoe1);
   secondgame.addItem(game1);

   secondbook->enter(customer1);
   secondbook->enter(customer2);
   secondbook->enter(customer3);

   secondbook->printCustomers();
   secondbook->exit(customer2);




    system("pause");
	return 0;
}
Example #2
0
int main()
{
	char ch_choice;
    string temp_str;
    double total_debt;

	string temp, temp_id, temp_id1, temp_id2, temp_id3;
    string item_prop1, item_prop2, item_prop3, item_prop4;

	Store* ptr_store;
	Store* temp_store;

    mall.setMallName("SHOPPING MALL");
    cout << "Welcome to the " << mall.getMallName() << " ! " << endl;

    // Create and initialize customers at system
    Customer* temp_customer = new Customer("");

	Customer* customer1 = new Customer("suheda");
	Customer* customer2 = new Customer("erman");
	Customer* customer3 = new Customer("ahmet");
	Customer* customer4 = new Customer("gokhan");
	Customer* customer5 = new Customer("mehmet");

    // Create and initialize stores at system
    Store* shoe_store = new ShoeStore("Steve Madden");
	Store* game_store = new GameStore("Gameland");
	Store* book_store = new BookStore("D&R");

    // Create and initialize shoe items
    Item* shoe_item1 = new Shoe("high heels", 150, 37, "female");
    Item* shoe_item2 = new Shoe("ankle boot", 200, 38, "female");
    Item* shoe_item3 = new Shoe("sport shoe", 120, 45, "male");
    Item* shoe_item4 = new Shoe("slipper", 45, 39, "female");
    Item* shoe_item5 = new Shoe("sandal", 110, 43, "male");

    //Create and initialize book items
    Item* book_item1 = new Book("Calikusu", 24, "Resat Nuri Guntekin", "Inkılap Kitabevi");
    Item* book_item2 = new Book("Kinyas ve Kayra", 25, "Hakan Gunday", "Om Yayınevi");
    Item* book_item3 = new Book("Karamazov Kardesler", 30, "Dostoyevski", "The Russian Messenger");
    Item* book_item4 = new Book("Ask", 23, "Elif safak", "Dogan Kitabevi");
    Item* book_item5 = new Book("Kurk Mantolu Madonna", 15, "Sabahattin Ali", "Yapı Kredi Yay.");

    //Create and initialize game items
    Item* game_item1 = new Game("Guitar Hero", 80, "audio/video", "Musical");
    Item* game_item2 = new Game("Football Manager", 90, "audio/video", "Football");
    Item* game_item3 = new Game("Sims", 100, "audio/video", "Role Playing");
    Item* game_item4 = new Game("World of Worcraft", 130, "audio/video", "Strategy");
    Item* game_item5 = new Game("Puzzle", 50, "Paper", "Puzzle");

    // Add shoe items to the shoe store
    shoe_store->addItemtoStore(*shoe_item1);
    shoe_store->addItemtoStore(*shoe_item2);
    shoe_store->addItemtoStore(*shoe_item3);
    shoe_store->addItemtoStore(*shoe_item4);
    shoe_store->addItemtoStore(*shoe_item5);

    // Add book items to the book store
    book_store->addItemtoStore(*book_item1);
    book_store->addItemtoStore(*book_item2);
    book_store->addItemtoStore(*book_item3);
    book_store->addItemtoStore(*book_item4);
    book_store->addItemtoStore(*book_item5);

    //Add game items to the item store
    game_store->addItemtoStore(*game_item1);
    game_store->addItemtoStore(*game_item2);
    game_store->addItemtoStore(*game_item3);
    game_store->addItemtoStore(*game_item4);
    game_store->addItemtoStore(*game_item5);

    // Create and initialize credit card object at the system
    // Account Limit is set to 1000 optionally.
    Payment* credit_card = new CreditCard(0, "4020230411018987", "visa", "03/15");
    credit_card->setLimit(CUSTOMER_ACCOUNT_LIMIT);

    // Create and initialize cash object at the system
    // Account Limit is set to 1000 optionally.
    Payment* cash = new Cash(0);
    cash->setLimit(CUSTOMER_ACCOUNT_LIMIT);

    // Create and initialize check object at the system
    // Account Limit is set to 1000 optionally.
    Payment* check = new Check(0, "Garanti Bankası", 220);
    check->setLimit(CUSTOMER_ACCOUNT_LIMIT);

    Item* temp_item;
    ItemToPurchase itpurchase;

    ShoppingCard* shopping_card = new ShoppingCard;

	mainmenu:
	printMainMenuText();
    getCharFromUserandStore(ch_choice);

    vector <ItemToPurchase> its;

	switch(ch_choice)
	{
	// Mall Menu
	case '1':
		mallmenu:
		printMallMenuText();

        getCharFromUserandStore(ch_choice);

		while (ch_choice != '6')
		{
			switch(ch_choice)
			{
			case '1':
				cout << "Customers which are waiting to enter mall. Choose one by typing its number.."<<endl;
                if(!customer1->getEntertoMallStatus())
					cout << "1. Suheda" << endl;

				if(!customer2->getEntertoMallStatus())
					cout << "2. Erman"  << endl;
				
				if(!customer3->getEntertoMallStatus())
					cout << "3. Ahmet" << endl;

				if(!customer4->getEntertoMallStatus())
					cout << "4. Gokhan" << endl;

				if(!customer5->getEntertoMallStatus())
					cout << "5. Mehmet"<< endl;

                getCharFromUserandStore(ch_choice);

				if (ch_choice == '1')
					mall.enter(*customer1);
				else if (ch_choice == '2')
					mall.enter(*customer2);
				else if (ch_choice == '3')
					mall.enter(*customer3);
				else if (ch_choice == '4')
					mall.enter(*customer4);
				else if (ch_choice == '5')
					mall.enter(*customer5);

				break;
			case '2':
				cout << "Enter the name of customer which will exit: ";
			    getStringFromUserandStore(temp_str);
                toLowerCaseSTD(temp_str);

                if(mall.getCustomerFromMall(temp_str, temp_customer))
                {			
					mall.exit(*temp_customer);
					cout << "Customer " << temp_str << " has exit the mall" << endl;
				}

				break;
			case '3':
				mall.printCustomers();
				break;
			case '4':
                if((mall.getStores()).size() != 0)
                {
				    mall.printStores();
                }
                else
                {
                    cout << "There are no stores at the mall right now! Please add store from main menu!" << endl;
                }
				break;
			case '5':
				cout << "\nChoose the type of store : (ShoeStore / GameStore / BookStore) : ";
		        getStringFromUserandStore(temp_str);
				if (temp_str == "ShoeStore")
				{
					mall.addStore(*shoe_store);
				}
				else if (temp_str == "GameStore")
				{
					mall.addStore(*game_store);
				}
				else if (temp_str == "BookStore")
				{
					mall.addStore(*book_store);
				}
                else
                {
                    cout << "You have entered invalid store type. Be careful about case sensitivity !" << endl;
                }
				break;
				
			default:
				break;
			}

			cin.clear();
			cin.sync();
			goto mallmenu;
		}

		cin.clear();
		cin.sync();

		goto mainmenu;

		break;
	// Store Menu
	case '2':
		storemenu:
		printStoreMenuText();

		getCharFromUserandStore(ch_choice);

		while(ch_choice != '5')
		{
			switch(ch_choice)
			{
			case '1':
            if((mall.getStores()).size() != 0)
            {
			    mall.printStores();

			    cout << "Which store do you want to enter ? Type its ID.." << endl;
                getStringFromUserandStore(temp_str);

			    if(mall.getStoreviaId(atoi(temp_str.c_str()), temp_store))
			    {
                    cout << "These are the customers which are currently at the mall :" << endl;
                    mall.printCustomers();
				    cout << "Enter your name :" << endl;
                    getStringFromUserandStore(temp_str);
                    toLowerCaseSTD(temp_str);

                    if(mall.getCustomerFromMall(temp_str, temp_customer))
				    {
					    (*temp_store).enter(*temp_customer);
				    }
			    }
            }
            else
            {
                cout << "There are no stores at the mall right now! Please add store from main menu!" << endl;
            }
			cin.clear();
			cin.sync();
				break;
			case '2':
            if((mall.getStores()).size() != 0)
            {
			    mall.printStores();

			    cout << "Which store do you want to exit ? Type its ID.." << endl;
			
                getStringFromUserandStore(temp_str);
			    if(mall.getStoreviaId(atoi(temp_str.c_str()), temp_store))
			    {
				    cout << "Enter your name :" << endl;

                    getStringFromUserandStore(temp_str);
                    toLowerCaseSTD(temp_str);

                    if(temp_store->getCustomerFromStore(temp_str, temp_customer))
				    {
					    (*temp_store).exit(*temp_customer);
				    }
			    }
            }
            else
            {
                cout << "There are no stores at the mall right now! Please add store from main menu!" << endl;
            }
			cin.clear();
			cin.sync();
				break;
			case '3':
                if((mall.getStores()).size() != 0)
                {
				    mall.printStores();
				    cout << "Choose a store. type its ID.." << endl;

				    cin >> temp;

				    if(mall.getStoreviaId(atoi(temp.c_str()), temp_store))
				    {
					    (*temp_store).printCustomers();
				    }
                }
                else
                {
                    cout << "There are no stores at the mall right now! Please add store from main menu!" << endl;
                }
				break;
			case '4':
                cout << "\nWhich store items do you want to show? : (ShoeStore / GameStore / BookStore) : ";

                getStringFromUserandStore(temp_str);
				if (temp_str == "ShoeStore")
				{
                    (*shoe_store).printItems();
				}
				else if (temp_str == "GameStore")
				{
                    (*game_store).printItems();
				}
				else if (temp_str == "BookStore")
				{
                    (*book_store).printItems();
				}
                else
                {
                    cout << "You have entered invalid store type. Be careful about case sensitivity !" << endl;
                }

				break;
			default:
				break;
			}
			goto storemenu;
		}