Example #1
0
/*Beginning of processPrint() routine
This function processes the user input. It decides the depth (from every bore hole), that is closest to the user input. 
Then it displays the data at that
depth to the user*/
void processPrint(struct holeStruct holeData[MAX_HOLES],float inputDepth,char label1[50], char label2[50],struct dimenssionStruct*dimenPtr,int choice,int legend)
{


				/*This proceedure takes the user input, loops through holeData[] array and calculates the minimum 
				difference between the user input and  soil depths  (as contained in holeData[..].soilData[..] array) for every bore hole
				This minimum difference is stored in min variable and the index of  depth at which the difference was minimum is stored
				in soilIndex variable.And  Soil Info at this depth is then displayed to the user*/
	
				int holeIndex;
				int soilCounter;
				int min=0;
				int soilIndex=0;
				double diff=0;


	
				//Erase graphics already drawn on the window
				eraseGraphics();
	

	
				//Uses a for loop to display all the bore hole information
				for(holeIndex=0;holeIndex<MAX_HOLES;holeIndex++)
				{
		
								printf("\n-------------------------------------------------------\n");
								printf("\n%s %s\n",label1,label2);
								printf("%s %lf %lf %d\n",holeData[holeIndex].Name,holeData[holeIndex].eastX,holeData[holeIndex].northY, holeData[holeIndex].numSamples);
	
								//Uses this nested for loop to calculate the depth from which soil information should be displayed
								for(soilCounter=0;soilCounter<holeData[holeIndex].numSamples;soilCounter++)
								{
												//Calculates the difference between user input and the actual depth
												diff=abs((holeData[holeIndex].soilData[soilCounter].depth)-(inputDepth));
			
												//If user input is not equal to the actual depth, then below code is executed
												if (holeData[holeIndex].soilData[soilCounter].depth !=inputDepth)
												{
																if(soilCounter==0  )
																{
																				//If this is the first time the loop is executing, assigns the difference to this var.
																				min=diff;
			
																}
																else if((min)>(diff))
																{
																				//If min var is greater than diff var, then min=diff
																				min=diff;
																				soilIndex=soilCounter;
				
			
																}
					
			
				
												}
			
												//If user input is equal to actual depth, then below code is executed
												else if(holeData[holeIndex].soilData[soilCounter].depth ==inputDepth)
												{
																soilIndex=soilCounter;
												}
		
		
			
								}
		
		
		
								//After calculations made above, below code prints the results on the Console
								printf("\n%s",label2);
								printf("%.2f ",holeData[holeIndex].soilData[soilIndex].depth);
		
								switch (choice)
								{
												case 1:
												{
																printf("%s\n",holeData[holeIndex].soilData[soilIndex].type);
																break;
												}
				
												case 2:
												{
																printf("%s\n",holeData[holeIndex].soilData[soilIndex].color);
																break;
												
												}
												case 3:
												{
				
																printf("%s\n",holeData[holeIndex].soilData[soilIndex].strength);
																break;
												}
												case 12:
												{	 
																printf("%s %s\n",holeData[holeIndex].soilData[soilIndex].type,holeData[holeIndex].soilData[soilIndex].color);
																break;
												}
									
												case 13:
												{
																printf("%s %s\n",holeData[holeIndex].soilData[soilIndex].type,holeData[holeIndex].soilData[soilIndex].strength);
																break;
												}
								
												case 23:
												{
				
																printf("%s %s\n",holeData[holeIndex].soilData[soilIndex].color,holeData[holeIndex].soilData[soilIndex].strength);
																break;
												}
								
												case 123:
												{
																printf("%s %s %s\n",holeData[holeIndex].soilData[soilIndex].type,holeData[holeIndex].soilData[soilIndex].color,holeData[holeIndex].soilData[soilIndex].strength);
																break;
												}
								
												default:
												{
												printf("\nInvalid Entry\n");
												break;
												}
			
								}
			
		
								/*After printing the results on the console, drawGraphics routine is called, which
								draws results on the Graphics Window*/
								drawGraphics(holeData,holeIndex,soilIndex,choice,dimenPtr,legend);
		
								legend=0;
				}
	
				printf("\nTotal Number of Bore holes: %d\nMinimum X: %.3lf; Maximum X: %.3lf; Range X: %.3lf\nMinimum Y: %.3lf; Maximum Y: %.3lf\n RangeY: %.3lf\n",MAX_HOLES,dimenPtr->minX,dimenPtr->maxX,dimenPtr->rangeX,dimenPtr->minY,dimenPtr->maxY,dimenPtr->rangeY);
		

}
Example #2
0
/*Displays the level 1 and level 2 menus to the user*/
void menu(rubix*myRubix)
{
	int level1MenuInput = 2;
	int level2MenuInput = 1;
	do
	{
		printf("Select mode of solution\n");
		printf("1. Manual Mode\n");
		printf("2. Automated Mode\n");
		printf("Enter your selection: ");
		
		
		fflush(stdin);
		scanf("%i", &level1MenuInput);
		
		
		switch (level1MenuInput)
		{
		case 1:
		{
			printf("\n----------------------------------------------------------\n");
			printf("\nManual Mode\nTransform Operations:\n");
			
			eraseGraphics();
			drawCubes(myRubix);
			
			do
			{
				printf("\nn0 = Switch rows for the nth column from the left, where n = 1,2,3,4\n");
				printf("\n7 = Rotate Upper row left one step\n");
				printf("\n1 = Rotate Lower row left one step\n");
				printf("\n2 = Rotate the mid four \"squares/numbers\" Clockwise one step\n");
				printf("\n8 = Rotate the mid four \"squares/numbers\" aNti-clockwise one step\n");
				printf("\nEnter Transform Operation (one at a time)");
				
				fflush(stdin);
				scanf("%i", &level2MenuInput);
				
				printf("\n----------------------------------------------------------\n");
				
				
				
				manualTransform(myRubix, level2MenuInput);
				
			}while (checkCube(myRubix) == 1);
			
			break;
			
			case 2:
			{
			
				printf("\n----------------------------------------------------------\n");
				
				printf("\nAutomated Mode\nTransform Operations:\n");
				printf("\nn0 = Switch rows for the nth column from the left, where n = 1,2,3,4\n");
				printf("\n7 = Rotate Upper row left one step\n");
				printf("\n1 = Rotate Lower row left one step\n");
				printf("\n2 = Rotate the mid four \"squares/numbers\" Clockwise one step\n");
				printf("\n8 = Rotate the mid four \"squares/numbers\" aNti-clockwise one step\n");
				
				printf("\n----------------------------------------------------------\n");
				
				automaticTransform(myRubix);
				
				break;
			}
		}
		default:
		{
			printf("\nError: You have entered an invalid menu option\n");
		}
		}
	}
	while (level1MenuInput != 1 && level1MenuInput != 2);
}