*MAFIA* Forums

*MAFIA* Forums

  • April 29, 2024, 05:03:02 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome back the Arcade! Play over 100+ games to get the high score and compete against other forum members.

http://www.mafiaowns.com/index.php?action=arcade;sa=list;sortby=a2z;

Author Topic: C# help.  (Read 2128 times)

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
C# help.
« on: May 24, 2006, 04:15:46 PM »

ok i need help with this. i didnt know where to post it so here it goes

ok im trying to make a game. well it's a project for school. here is what i have to do .
Write an application that plays "guess the number" as follows: Your application chooses the number to be guessed by selecting a random integer in the range 1 to 1000. The application displays the promp Guess a number between 1 and 1000. The player inputs a first guess. If the player's guess is incorrect, your application should display Too high. Try Again. or Too low. Try again. to help the player "zero in" on the correct answer. The application should prompt the user for the next guess. When the user enters the correct answer, display Congratulation s. You guessed the number! and allow the user to choose wether to play again.

here is what i have so far, not much but hey, so if anyone can help i would really appreciate it.

using System;


public class GuessingGame
{
public static void Main (string[]args)
{
Random randomNumber = new Random();
int mainNumber;

for (int counter = 1; counter <=1; counter++)
      {
         mainNumber = randomNumber.N ext(1,1001);
      }

Console.WriteL ine("Number is set,  Guess a number between 1 and 1000");
      int guess = Convert.ToInt3 2(Console.ReadLi ne()); //read guessed number

EDIT: oh yeah this is a console application.
« Last Edit: May 24, 2006, 04:30:47 PM by *MAFIA* ChrisDaKilla »
Logged

*MAFIA* Bonehead

  • *MAFIA* Founder
  • Forum Member
  • Reputation: 2584
  • Offline Offline
  • Posts: 8,007
    • View Profile
    • *MAFIA*
C# help.
« Reply #1 on: May 24, 2006, 05:52:41 PM »

I may have an old borland app that does just that :p let me look later and if I do you can have the source ;)
Logged

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
C# help.
« Reply #2 on: May 24, 2006, 07:48:49 PM »

sounds good boner.
Logged

Rahl

  • Forum Member
  • Reputation: 279
  • Offline Offline
  • Posts: 379
    • View Profile
C# help.
« Reply #3 on: May 24, 2006, 10:41:03 PM »

Here is the general idea in good ole C/C++.  Have fun with that.

void main()
{
    int daGuess;
    int daNumber = rand() % (1000 - 1) + 1 // Left in this form for a purpose

    do
    {
        cout << "Enter your guess: ";
        cin >> daGuess;
        cout << endl;

        determineCours e(daGuess, daNumber);
     } while(daGuess != daNumber);
}

void determineCours e(int aGuess, int goal)
{
     if(goal > aGuess)
            cout << "Your guess is too low.  Try again." << endl;
     else if(aGuess > goal)
            cout << "Your guess is too high.  Try again." << endl;
     else
            cout << "Congratu-fucking-lations.  You've gotten it right." << endl;
}
Logged

Boemann (nl)

  • Forum Member
  • Reputation: 1155
  • Offline Offline
  • Posts: 1,985
    • View Profile
C# help.
« Reply #4 on: May 25, 2006, 12:05:48 AM »

Lol, I made that program on my scientific calculater, its not c++ though but it sure worked nice :P
Logged

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
C# help.
« Reply #5 on: May 25, 2006, 09:22:53 AM »

for sure we do. took me 12 guesses to get the correct number.

EDIT: in order to run this you must have the .NET Framework Installed.
« Last Edit: May 25, 2006, 05:09:31 PM by *MAFIA* ChrisDaKilla »
Logged
 

Page created in 0.042 seconds with 30 queries.