Ch 10 Section 8 : Alternative Way to Code CreateContract

Ch 10 Section 8 : Alternative Way to Code CreateContract

This code borrows from the function 'ChangeInfo'. Essentially, it initializes a string to include all the properties and then loops through the string seeking info on each property - which is just what should happen with a new contract.

void CreateContract(int contractID, Contract& contract)
{  String80  properties = "12345"; // The 'options' for creating string prompts
	// Copy code from function 'ChangeInfo'

	String80 string;
	int index = 0;
	while (properties[index])
	{	switch (properties[index])
		{  case '1':
				GetNewString(string, "ContracteeName");
				contract.ChangeContracteeName(string);
				break;

			case '2':
				GetNewString(string, "Office Street Address");
				contract.ChangeOfficeStreetAddress(string);
				break;
			case '3':
				GetNewString(string, "Office City");
				contract.ChangeOfficeCity(string);
				break;
			case '4':
				GetNewString(string, "Office State");
				contract.ChangeOfficeState(string);
				break;
			case '5':
				GetNewString(string, "Office Zip Code");
				contract.ChangeOfficeZip(string);
				break;
			case '6':
				int sqFootage;
				sqFootage = GetSquareFootage();
				contract.ChangeSquareFootage(sqFootage);
				break;
			case '7':
				int numDesks;
				numDesks = GetNumDesks();
				contract.ChangeNumDesks(numDesks);
				break;
			case '8':
				int numDays;
				numDays = GetNumDays();
				contract.ChangeNumDays(numDays);
				break;
			default:
				cout << endl << properties[index] << " is an invalid code.\n";

		}  // end switch
		index++;
	} // end while

        int sqFootage;
	sqFootage = GetSquareFootage();
	contract.ChangeSquareFootage(sqFootage);

	int numDesks;
	numDesks = GetNumDesks();
	contract.ChangeNumDesks(numDesks);

	int numDays;
	numDays = GetNumDays();
	contract.ChangeNumDays(numDays);

	clrscr();
	DisplayInfo(contract);
}