It217 week 7 assignment | Computer Science homework help

 Modify the Guessing game from chapters 6-7 to play with 2 players instead of 1 player by showing input and stats for player 1 and player 2.
– To end the game: You can ask for number of games to be played at the beginning of the game or you can ask the user whether to continue after each game.
– Display number of guesses for each player in addition to average number of guesses for each play.
– Show which player wins the whole match based on who has the least average number of guesses after the total number of games selected is over.
– When each game is played, change the output to display that the last guess is correct. Example: Congratulations! XXX is correct!
– When the players reach the total number of games chosen, or when the player chooses not to continue, display either: “Match over! Player 1 wins!” , OR “Match over! Player 2 wins!” , OR “Match over! It’s a tie!” 

MODIFY THE PROGRAM BELOW WITH THE PROVIDED INSTRUSTION UP IN just BASICSOFTWARE

‘ *************************************************************************

‘ Script Name: GuessMyNumber.bas (The Guess My Number Game)

‘ Version:     1.0

‘ Author:      Jerry Lee Ford, Jr.

‘ Date:        March 1, 2007

‘ Description: This game is a Just BASIC number guessing game that

‘              challenges players to guess a number between 1 and 100 in

‘              as few guesses as possible.

‘ *************************************************************************

nomainwin   ‘Suppress the display of the default text window

‘Declare global variables used to keep track of game statistics

global secretNumber, avgNoGuesses, noOfGamesPlayed, guessCount, helpOpen$

‘Assign default values to global variables

secretNumber = 0    ‘Keeps track of the game’s randomly generated number

guessCount = 0      ‘Keeps track of the total number of guesses made

avgNoGuesses= 0     ‘Stores the calculated average number of moves per game

noOfGamesPlayed = 0 ‘Keeps track of the total number of games played

helpOpen$ = “False” ‘Keeps track of when the #help window is open

WindowWidth = 510   ‘Set the width of the window to 500 pixels

WindowHeight = 500  ‘Set the height of the window to 500 pixels

ForegroundColor$ = “Darkblue”  ‘Set the window font color to dark blue

‘Define the format of statictext controls displayed on the window

statictext #play.statictext1, “G U E S S   M Y   N U M B E R”, _

  30, 50, 440, 40

statictext #play.statictext2, “Copyright 2007”, 395, 90, 80, 20

statictext #play.statictext3, “Games Played:”, 40, 400, 80, 20

statictext #play.statictext4, “Avg. No. Guesses:”, 265, 400, 90, 20

statictext #play.statictext5, “Enter Your Guess:”, 200, 140, 100, 20

statictext #play.statictext6, “Hint:”, 42, 300, 30, 20

‘Add button controls to the window

button #play.button1 “Guess”, AnalyzeGuess, UL, 210, 225, 80, 30

button #play.button2 “Help”, DisplayHelp, UL, 400, 318, 70, 25

button #play.button3 “Start Game”, StartGame, UL, 400, 288, 70, 25

‘Add three textbox controls and place them inside the groupbox control

textbox #play.textbox1, 200, 160, 100, 50

textbox #play.textbox2, 130, 395, 90, 22

textbox #play.textbox3, 370, 395, 90, 22

textbox #play.textbox4, 40, 320, 340, 22

‘Open the window with no frame and a handle of #play

open “Guess My Number” for window_nf as #play

‘Set up the trapclose event for the window

print #play, “trapclose ClosePlay”

‘Display the appropriate variable values in the following textbox controls

print #play.textbox3, avgNoGuesses

print #play.textbox2, noOfGamesPlayed

‘Set the font type, size, and properties for each of the static controls

print #play.statictext1, “!font Arial 24 bold”

print #play.statictext2, “!font Arial 8”

print #play.statictext5, “!font Arial 8 bold”

print #play.statictext6, “!font Arial 8 bold”

print #play.textbox1, “!font Arial 24”;

print #play.button3, “!setfocus”;  ‘Set focus to the Start Game button

print #play.button1, “!disable”    ‘Disable the Guess button

print #play.textbox1, “!disable”   ‘Disable the input textbox

‘Pause the application to wait for the player’s instruction

wait

‘This subroutine analyzes player guesses and determines when the game

‘has been won

sub AnalyzeGuess handle$

  ‘Retrieve the player’s guess and assign it to a variable

  print #play.textbox1, “!contents? playerGuess”

  ‘Validate that an acceptable value has been entered

  if playerGuess < 1 or playerGuess > 100 then

    ‘Inform the user that an invalid guess has been made

    print #play.textbox4, “Your guess must be between 1 and 100. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess is too low

  if playerGuess < secretNumber then

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

    ‘Inform the user that the guess was too low

    print #play.textbox4, “Your guess was too low. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess is too high

  if playerGuess > secretNumber then

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

    ‘Inform the user that the guess was too high

    print #play.textbox4, “Your guess was too high. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess was correct

  if playerGuess = secretNumber then

    ‘Let the player know he has won the game

    notice “Guess My Number” + chr$(13) + “Game over! You win!”

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

   ‘Increment the variable that tracks the total number of games played

    noOfGamesPlayed = noOfGamesPlayed + 1

    ‘Calculate the average number of guesses per game

    avgNoGuesses = guessCount / noOfGamesPlayed

    ‘Display the appropriate variable values in the following textbox

    ‘controls

    print #play.textbox3, avgNoGuesses

    print #play.textbox2, noOfGamesPlayed

    print #play.textbox1, “”           ‘Clear out the input textbox

    print #play.button3, “!enable”     ‘Enable the Start Game button

    print #play.button3, “!setfocus”;  ‘Set focus to the Start Game button

    print #play.textbox1, “!disable”   ‘Disable the input textbox

    print #play.button1, “!disable”    ‘Disable the Guess button

    print #play.textbox4, “”           ‘Clear out the Hint textbox control

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

end sub

‘This subroutine is called when the player clicks on the Start Game button

sub StartGame handle$

  ‘Generate a new random number for the game

  secretNumber = int(rnd(1)*100) + 1

  print #play.button1, “!enable”      ‘Enable the Guess button

  print #play.textbox1, “!enable”     ‘Enable the input textbox

  print #play.button3, “!disable”     ‘Disable the Start Game button

  print #play.textbox1, “!setfocus”;  ‘Set focus to the input textbox

end sub

‘This subroutine is called when the player clicks on the Help button

sub DisplayHelp handle$

  helpOpen$ = “True”  ‘Identify the #help window as being open

  WindowWidth = 400   ‘Set the width of the window to 500 pixels

  WindowHeight = 400  ‘Set the height of the window to 500 pixels

  ‘Use variables to store text strings displayed in the window

  HelpHeader$ = “Game Instructions”

  helpText1$ = “The object of this game is to guess a randomly generated” _

    + ” number in the range of 1 to 100 in as few guesses as possible. ” _

    + “To make a guess, type in a number and click on the Guess button. ” _

    + “A hint will be provided after each move to assist you in making ” _

    + “your next guess. Once you have correctly guessed the game’s secret” _

    + ” number, a popup message will be displayed.”

  helpText2$ = “At the end of each round of play, game statistics are ” _

    + “displayed at the bottom of the game window as an indication of ” _

    + “your progress.”

  ‘Define the format of statictext controls displayed on the window

  statictext #help.helptext1, HelpHeader$, 30, 40, 140, 20

  statictext #help.helptext2, helpText1$, 30, 70, 330, 80

  statictext #help.helptext3, helpText2$, 30, 160, 330, 50

  ‘Add button controls to the window

  button #help.button “Close”, CloseHelpWindow, UL, 280, 310, 80, 30

  ‘Open the window with no frame and a handle of #play

  open “Guess My Number Help” for window_nf as #help

  ‘Set the font type, size, and properties for specified statictext control

  print #help.helptext1, “!font Arial 12 bold”

end sub

‘This subroutine is called when the player closes the #help window

sub CloseHelpWindow handle$

  helpOpen$ = “False”  ‘Identify the #hlp window as being closed

  close #help  ‘Close the #help window

end sub

‘This subroutine is called when the player closes the #play window

‘and is responsible for ending the game

sub ClosePlay handle$

  ‘Get confirmation before terminating program execution

  confirm “Are you sure you want to quit?”; answer$

  if answer$ = “yes” then  ‘The player clicked on Yes

    close #play  ‘Close the #play window

    ‘See if the #help window is open and close it if it is

    if  helpOpen$ = “True” then

      call CloseHelpWindow “X”  ‘Close the #help window

    end if

    end  ‘Terminate the game

  end if

end sub

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.

Essays

Research Papers

At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.

Admissions

Thesis Writing Service

Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?

Editing

Custom Papers

Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.

Coursework

Essay Writing

Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.

Coursework

Coourse Work Writing

Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !

Coursework

Dissertation Writing Service

High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.