GithubHelp home page GithubHelp logo

kylelangley280 / twfcs_number_guessing_game Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

This is a project created in my Computer Programming I class but is being uploaded for my Technical Writing for Computer Science course.

twfcs_number_guessing_game's Introduction

TWFCS_Number_Guessing_Game

Introduction

My name is Kyle Langley and this code I have uploaded was originally made as a mid-term project for my Computer Programming I class during my freshman spring semester at college. The basis of this code is a random number guessing game. For this game, the computer randomly picks a number of a set length and set size, and you must guess a number within those margins. The computer will tell you how many numbers you have correct and are in their correct positions and how many numbers you have correct but are misplaced but will not specify which number out of your numbers guessed it is talking about. You only have a set amount of guesses, so think carefully!

One Example of the Finished Program

randomnumbergenerator1

How to download? How to run?

This project was coded in the C++ IDE: #### DEV C++ #### To download this IDE go to: https://sourceforge.net/projects/orwelldevcpp/files/latest/download

When you download the included project, first unzip the project. Once you have Dev C++ downloaded and open, run the Project1.dev file and it should open up all the included files needed to run the program. Once opened, press the compile and run button (F11) and it should load up on its own!

Summary

This project is made up of three files: the main.cpp, the Project1.h, Project1.cpp.

The Project1.h consists of declarations of variables and functions.

The Project1.cpp controls most of the system output of the program and controls much of the input as well. The input given is also ran through a length-checker to make sure that the input given fits the fixed code length.

The main.cpp is the biggest of the files and actually has most of the game-running code. The beginning of this file contains most of the variables used to hold user inputs and guesses. The game is created to run off of a while loop. This while loop can be found on line 44 of the main file and is set to run off of a game_over variable. As long as game_over is false, the program continues to run. This switch is set to true when either the user uses all of their guesses (designated by the MAX_GUESSES variable) or gets the number correct. The chunk of the while loop is made up of two for loops. These two for-loops cycle through the computer-generated number and the user-entered number and first checks to see what digits match perfectly and then check to see what numbers match but are misplaced in the user’s guess. If all numbers match, the game_over variable is switched to true and the user wins.

The rest of the code in main.cpp is used to print whether the user wins or loses (in how many guesses) and asks if the user would like to play again. Depending on the answer (Y/N), the program chooses to run again or stop. If the user chooses to stop, the program thanks the user and closes.

Extra Control

The three changable variables in this program that can be altered to increase or decrease difficulty are: number of max guesses, the codespan (how big the numbers can be), or the codelength (how long the generated code actually is)

randomnumbergeneratorvariables

These three variables can be changed at the start of the main file and once altered will change the program on its own. Just remember to re-compile and run to keep your changes.

twfcs_number_guessing_game's People

Contributors

kylelangley280 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.