Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.191.202.48
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/acyurksaitis/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/acyurksaitis/menue2.cpp
// function template
#include <iostream>
using namespace std;

// prototypes
void menu();
void process();
const int MAX = 100;


template <class T>
class List
{
	int length;
	T name[MAX];
public:
	List()
	{
		length = 0;
	}
	int Length () const
	{
		return length;
	}
	void INsert (T item)
	{
		data[length] = item;
		length ++;
	}

int main()
{
	char ch;
	string a, b, c;
	menu();
	cin >> ch;
	while(tolower(ch) != 'q')
	{
		switch (tolower(ch))
		{	case 'i':	
				cout << "\n\n\n\tNow play the integer game:  ";
				process<int>();
				break;
			case 'c':
				cout << "\n\n\n\tNow play the character game:  ";
				process<char>();	
				break;
			case 's':
                                cout << "\n\n\tNow play the string game:  ";
				
				break;
			default:
				cout << "\n\tInvalid, redo it\n\n";
		}
		menu();
		cin >> ch;
	}
	cout << "\n\nBye.\n\n";
	return 0;
}
//---------------------------------
template<class T>
void process()
{	
	char selection;
	List z;
	T item;

	menuForList();
	cin >> selection;
	while(tolower(selection) != 'q')
	{	
		switch (tolower(selection))
		{
			case'i':	
				cout <<"Input an item: ";
				cin >> item;
				z.Insert(item); break;
			case'p':
				cout << "\n\nThe list is: \n";
				z.Print();	break;
			default:
				cout <<"\n\nInvalid. Try again...\n\n";
		}
}


//---------------------------------
void menu()
{
	cout << "\n\n\t--- Welcome to the Bigger Game! ---\n";
	cout << "\t    =========================\n\n";
	cout << "\t  I	 Integers\n";
	cout << "\t  C	 Characters\n";
	cout << "\t  X	 General strings\n";
	cout << "\t  Q	 Quit\n";
	cout << "\t--------------------\n";
	cout << "\n\tYour choice: ";
} 
void menueForList()
{	
	cout << "\n\t==========================================\n\n" <<endl;	 
	cout << "\t  I   to insert an item to the list.\n";
//	cout << "\t  F   to find a item on the list.\n";
	cout << "\t  P   to print the list.\n";
//	cout << "\t  S   to sort the list in ascending order.\n";
	cout << "\t  Q   to quit the operation.\n";
	cout << "\t \nYou choose: ";
}

Stv3n404 - 2023