int main() {
  int option;
  Circle* cir = 0;
  Rectangle* rec = 0;
  Box* box = 0;
  Cylinder* cy = 0;

  do {
    cout <<
      "\nMAIN MENU                                  "
      "\n  1. Rectangle Tasks                       "
      "\n  2. Circle Tasks                          "
      "\n  3. Mixed Rectangle & Circle Tasks        "
      "\n  4. Box Tasks                             "
      "\n  5. Cylinder Tasks                        "
      "\n  6. All Object Tasks                      "
      "\n  7. Quit                                  ";

    cout << "\nEnter your option (1 to 7): ";
    cin >> option;

    switch (option) {
    case 1:
      rectangleMenu(&rec);
      break;
    case 2:
      circleMenu(&cir);
      break;
    case 3:
      mixedMenu(rec, cir);
      break;
    case 4:
      boxMenu(&box);
      break;
    case 5:
      cylinderMenu(&cy);
      break;
    case 6:
      allObject(rec, cir, box, cy);
    case 7:
      cout << "\n Having fun." << endl;
      break;
    default:
      cout << "\n Wrong Option." << endl;
    }
  } while (option != 7);
  return 0;
}
Beispiel #2
0
void CntMenu(container **cHead, int numCnt){
	int choice, number;
	container *n = NULL;
	printf("Enter number of container for opening. Total amount of containers: %d\n", numCnt);
	scanf("%d", &number);
	if (number > numCnt || number < 1){
		printf("Incorrect number. Error opening\n.");
		return;
	}
	n = (*cHead);
	for (int i = 0; i < number - 1; i++){
		n = n->next;
	}
	printf("Container #%d opened succesfull\n", number);
	printf("Press any key to continue\n");
	getch();

	box *bHead = n->head, *bTail = n->tail, *bCurrent = NULL;
	do{
		system("cls");
		printf("Container #%d menu:\n", number);
		printf("1. Show contents of all boxes\n");
		printf("2. Open box\n");
		printf("3. Add box\n");
		printf("4. Delete box\n");
		printf("5. Back to main menu\n");
		scanf("%d", &choice);
		system("cls");
		switch (choice){
		case 1:
			contents(bHead);
			printf("Press any key for return to main menu...\n");
			getch();
			break;
		case 2:
			boxMenu(&bHead, n->qtBoxes, number);
			break;
		case 3:
			if (bHead == NULL)
				bHead = new box;
			else if (bTail == NULL){
				bTail = new box;
				bHead->next = bTail;
			}
			else{
				bCurrent = new box;
				bTail->next = bCurrent;
				bTail = bCurrent;
			}
			n->qtBoxes++;
			printf("Box #%d successfully added\n", n->qtBoxes);
			printf("Press any key for return to container menu...\n");
			getch();
			break;
		case 4:
			deleting(&bHead, n->qtBoxes, &bTail);
			printf("Press any key for return to container menu...\n");
			getch();
			break;
		}
	} while (choice != 5);
}