1. Homepage
  2. Programming
  3. CS 162 Assignment #1 Go Hooping

CS 162 Assignment #1 Go Hooping

Engage in a Conversation
CS162Software EngineeringC++

CS 162 Assignment #1 Go Hooping CourseNana.COM

Goals: CourseNana.COM

● Practice good software engineering design principles: o Design your solution before writing the program o Develop test cases before writing the program CourseNana.COM

  • ●  Review conditionals, loops, functions, and basic contiguous buffers (arrays) CourseNana.COM

  • ●  Use functions to modularize code to increase readability and reduce repeated code CourseNana.COM

    Problem Statement: CourseNana.COM

    You are tasked with implementing a C++ program that simulates a basketball shooting game for a local high school. The game supports 2 players, with each player attempting to score as many points as possible by making shots from five fixed shooting positions. CourseNana.COM

    At each shooting position, there is a rack of five basketballs. Out of the five balls, the first four are regular balls, worth one point each. The fifth ball, often nicknamed the "money ball", is worth two points. The “money ball” can only be shot after the four regular balls are shot. CourseNana.COM

    Of those five positions, the player can choose a position to have a rack consisting only of "money balls", which are all worth two points. This position is called the “money-ball rack”. CourseNana.COM

    Additionally, two ball pedestals are positioned at “Starry Range” (two deep shot locations between racks 2 and 3 and the other between racks 3 and 4. Each ball pedestal holds one special white “Starry” ball. Shots made with the white “Starry” ball are worth 3 points. CourseNana.COM

    The goal of this game is to score as many points as possible. Player 1 needs to finish shooting from all five positions before the next player shoots. The player with the highest score at the end of the game is the winner. CourseNana.COM

    After the game is completed, the players will have the option to play again or quit. The program should keep restarting from the beginning until the players eventually decide to quit. CourseNana.COM

    Here is a video demonstration of the shooting game concept (ignore the shot clock restriction) CourseNana.COM

Implementation Requirements: CourseNana.COM

  1. Before each player’s shooting, prompt them to choose the “money-ball rack” position. The program should re-prompt until a valid input is given. CourseNana.COM

  2. For both players, assume there is always a 50% chance of successfully making the shot, no matter if it is for the regular balls, the money balls, or the Starry ball. CourseNana.COM

  3. For each player, you must use at least one array to keep track of the results of each shot (e.g., which shots missed vs which shots made it). The results of the starry ball shots do not have to be stored in an array (though they can be), but the results of the other 25 shots do. CourseNana.COM

1. You may not use the STL for this assignment (e.g., std::array, std::vector, etc). We’ll be covering the STL later; for this assignment, it’s imperative that you demonstrate knowledge of basic buffers. That’s to say, your array must be a regular C/C++ array (statically allocated or dynamically allocated—there’s extra credit involving a dynamically allocated array) CourseNana.COM

  1. The shooting result of each player should be displayed using the following notation: CourseNana.COM

  2. For each player, the program needs to display the scores for each rack, and the total score. CourseNana.COM

  3. After both players have completed their shooting, declare the winner (or a tie game). CourseNana.COM

  4. Prompt the players whether they want to play again or quit the game. If they want to play again, CourseNana.COM

    restart from the beginning. Otherwise, the program should terminate gracefully (you should not use the exit() function for this; using the exit() function is generally considered bad practice—your program should end “naturally” by reaching the end of the main() function). CourseNana.COM

  5. Your program must scold the user and reprompt any time they supply a bad value, but not a bad data type. For example, when your program asks the user for an integer between 1 and 5 (e.g., for the money ball rack position), you may assume that the user will enter some sort of integer. However, you may not assume that they will specifically enter an integer between 1 and 5. Your program must check whether the user’s entered integer is between 1 and 5 and, if not, scold them for their invalid input and reprompt (in a loop) until they eventually supply a valid value. CourseNana.COM

  6. Your user interface must provide clear instructions for the user and information about the data being presented CourseNana.COM

  7. Your code must adhere to the course’s C++ style guidelines (including the SRP and DRY principles—you should have many modular functions in your implementation) CourseNana.COM

  8. Your code most compile and run (without runtime errors, like segmentation faults). If your code does not compile or run correctly, large portions of your assignment may go ungraded, potentially resulting in a zero in the gradebook (this policy is outlined in the syllabus). CourseNana.COM

Example Output: (User inputs are highlighted)
Note: You don’t have to follow the example output exactly, but you need to display all required fields and they must be readable. CourseNana.COM

(Example output starts on the next page) CourseNana.COM

Welcome to the basketball shooting contest! CourseNana.COM

Player 1:
Where do you want to put your money-ball rack? Enter 1-5: 8
CourseNana.COM

Invalid input, try again. CourseNana.COM

Where do you want CourseNana.COM

to put your money-ball rack? Enter 1-5: 4 CourseNana.COM

| 4 pts | 3 pts |0pts | 5 pts |3pts | 8 pts | 2 pts CourseNana.COM

to put your money-ball rack? Enter 1-5: -8 That’s not a valid input. CourseNana.COM

Rack 1: _ Rack 2: O Starry: _ Rack 3: O Starry: S Rack 4: M Rack 5: O CourseNana.COM

Total: 25 CourseNana.COM

Player 2:
Where do you want
CourseNana.COM

Where do you want CourseNana.COM

to put your money-ball rack? Enter 1-5: 5 CourseNana.COM

| 0 pts | 1 pts |0pts | 6 pts |0pts | 2 pts | 10 pts CourseNana.COM

Rack 1: _ Rack 2: O Starry: _ Rack 3: O Starry: _ Rack 4: O Rack 5: M CourseNana.COM

Total: 19
Player 1 is the winner!!
Do you want to play again? (1-yes, 0-no): 3
CourseNana.COM

Sorry, that’s not a valid input.
Do you want to play again? (1-yes, 0-no): 0
CourseNana.COM

CourseNana.COM

(15 pts) Extra Credit: N players using Dynamic Arrays CourseNana.COM

Instead of supporting only two players, modify the program so it can support N players, where N is a positive integer supplied by the user.
Additional implementation requirements:
CourseNana.COM

  • ●  The value of N is determined by a user input during runtime at the start of the program. CourseNana.COM

  • ●  Use dynamic arrays allocated on the heap to keep track of the total scores of each player (you do CourseNana.COM

    not have to store all players’ shooting results in a gigantic multidimensional dynamic array; however, you do need to keep track of every player’s total score in one dynamic array [containing a total of N integers], and you do still need to use arrays to store players’ shooting results in some way or another, as per the regular assignment requirements). CourseNana.COM

  • ●  Your program must not have memory leaks. Make sure you use valgrind to check this! CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
CS162代写,Software Engineering代写,C++代写,CS162代编,Software Engineering代编,C++代编,CS162代考,Software Engineering代考,C++代考,CS162help,Software Engineeringhelp,C++help,CS162作业代写,Software Engineering作业代写,C++作业代写,CS162编程代写,Software Engineering编程代写,C++编程代写,CS162programming help,Software Engineeringprogramming help,C++programming help,CS162assignment help,Software Engineeringassignment help,C++assignment help,CS162solution,Software Engineeringsolution,C++solution,