Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Name: Antar Vasi
- * Class: ECCS 164 SEC 02
- * Assignment: Lab 6
- * Purpose: To create a children's math game with a
- * random number generator and a score count.
- * Date Assigned:
- * Date Due: 10/23/06
- */
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication2
- {
- class childrensGame
- {
- static void Main()
- {
- Random random1 = new Random();
- DisplayGame();
- }
- // This method will display the game to the user directly.
- //////////////////NON-WORKING/////////////////////////
- public static void DisplayGame
- (int op1, string operation, int op2, int totalScore)
- {
- Console.WriteLine("Welcome to the game.");
- op1 = generateNumber(//what goes here?);
- op2 = generateNumber(//what goes here?);
- operation = generateOperation(//what goes here?);
- Console.WriteLine("What is {0} {1} {2}", op1, operation, op2);
- }
- // This method generates a random number from 1 to 10
- // and will return this random number to the Main function.
- //////////////////////WORKS///////////////////////
- public static int generateNumber(Random random2)
- {
- int rndNumber;
- rndNumber = random2.Next(0, 10);
- return rndNumber;
- }
- //This method generates a random operation.
- /////////////////NON-WORKING////////////////////
- public static string generateOperation(Random random3)
- {
- int rndNumber2 = random3.Next(0, 3);
- if (rndNumber2 == 0) // Addition operation
- {
- Console.Write("+");
- }
- else if (rndNumber2 == 1) // Subtraction operation
- {
- Console.Write("-");
- }
- else // Multiplication operation
- {
- Console.Write("*");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment