CSE224 Assignment 3 Solved

30.00 $

Category:

Description

Rate this product

In this assignment, you’re going to create a bash script that will play High-Low against a user. Specifically:

  • the user will type the name of your script (“hl”) and hit ENTER
  • the program will print a welcome message, tell the user about playing high-low, and

    tell them which keys to use during gameplay; then ask the user to think of a

    number between 1 and 100 (inclusive), and to hit any key when they’re ready

  • the user thinks of a number, and then hits any key
  • the program will make a guess and tell the user what the guess is.
  • if the program’s guess was correct, the user hits the ‘c’ key, and the game is over.

    Tell the user how many guesses it took, thank the user for playing, and exit (alternatively, you may insult the user for picking such an easy number, describe how brilliant the program is, and so on) Otherwise:

  • if the program’s guess was too high (large), the user hits the ‘h’ key
  • if the program’s guess was too low (small), the user hits the ‘l’ key
  • the program makes another guess, tells the user what the guess is, and the game

    continues.

    Additionally, if the user runs highlow with an argument, then the player can pick a number between 1 and whatever the argument is. for example, if they say

    hl 1000
    then the user may guess a number between 1 and 1000. If an argument is given, you

    may assume it is a positive integer, and ignore any additional arguments.

    DETAILS:

  • This must be written as a bash script
  • you must comment your code, including in the beginning your name, class name,

    date, and a description of what the program does. Also comment the code itself

  • don’t require the user to hit ENTER after typing h l or c: your script should look for

    a single keystroke and then continue

  • We’ll go over the algorithm in class for playing high-low
  • your program should detect cheating. For example, if 51 is high and 50 is low, the

    user must be cheating (or they made a mistake in answering). Detect this type of

    situation, inform the user, and exit the game.

  • name the script hl and push to a GITLab repo named “HL” by the due date.

    BE SURE OF THE FOLLOWING:

  • the user is picking a number, and the program is trying to guess it (not the other

    way around)

  • ‘h’ means the program’s guess was too high, ‘l’ means too low. If the user is thinking

    of the number 10 and the program guesses 50, that’s high (‘h’). If the program

    guesses 2, that’s low (‘l’)

  • the program begins by asking the user to think of a number, and having them hit

    any key when they’ve got a number in mind. It then immediately begins playing the

    game by making its first guess.

  • If the user hits anything other than h, l or c, you should print a one-line message

    reminding the user which keys they can use.

  • Feel free to have other students test your game for you!
  • cse224-assignment-3-main-tzinlw.zip