In C++ program
Fishing Game Simulation
For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Each possible item is worth a certain number of fishing points. The points will not be displayed until the user has finished fishing, and then a message is displayed congratulating the user depending on the number of fishing points gained.
Here are some suggestions for the game’s design:
To implement this game, create a class named FishingGame that includes the appropriate functions for carrying out the above requirements.
#include <iostream>
#include <string>
using namespace std;
class Die
{
public:
static int rollDie(int numSides)
{
if (numSides < 1)
return 0;
return 1 + rand() % numSides;
}
static int rollD6()
{
return rollDie(6);
}
};
class FishingGame
{
private:
int score;
public:
FishingGame()
{
score = 0;
}
int calculateScore(int fish)
{
// Determine number of points for fish
// and return it.
return 0;
}
string castLine()
{
int fish = Die::rollD6();
// TODO: Determine a number of points for the fish.
// Call the calculateScore function and add
// results to score.
// TODO: Return a description of the fish.
// Examples: "a big fish", "an old shoe", etc.
return "";
}
int getScore()
{
// Return the score.
return 0;
}
string getFeedback()
{
// If player earned a good score, congratulate him/her.
// else encourage him/her to try again.
return "";
}
};
int main()
{
FishingGame game; // Create the game object.
// Repeat until user is ready to quit.
{
// Cast a line.
cout << "You caught " << game.castLine() << endl;
// prompt user to keep playing or quit
}
// Display score.
// Display feedback.
// Keep this stuff at the end.
cout << endl;
system("pause");
return 0;
}Thanks for the question.
Here is the completed code for this problem. Let me know if you
have any doubts or if you need anything to change.
Thank You !!
=========================================================================================
#include <iostream>
#include <string>
#include<cstdlib>
using namespace std;
class Die
{
public:
static int rollDie(int numSides)
{
if (numSides < 1)
return 0;
return 1 + rand() % numSides;
}
static int rollD6()
{
return rollDie(6);
}
};
class FishingGame
{
private:
int score;
public:
FishingGame()
{
score = 0;
}
int calculateScore(int fish)
{
int scores[] ={10,2,50,1,4,2};
score+=scores[fish-1];
return 0;
}
string castLine()
{
int fish = Die::rollD6();
string treasure[]={" A big fish","An old
shoe","A golden penny","A nail","A fish net","An oyster"};
// TODO: Determine a number of points for the fish.
// Call the calculateScore function and add
// results to score.
// TODO: Return a description of the fish.
// Examples: "a big fish", "an old shoe", etc.
calculateScore(fish);
return treasure[fish-1];
}
int getScore()
{
// Return the score.
return this->score;
}
string getFeedback()
{
// If player earned a good score, congratulate him/her.
// else encourage him/her to try again.
if(this->score>100){
return "You scored a good score!";
}else{
return "Better luck catching fish next time";
}
}
};
int main()
{
FishingGame game; // Create the game object.
char playAgain='n';
// Repeat until user is ready to quit.
do
{
// Cast a line.
cout << "You caught " << game.castLine() <<
endl;
// prompt user to keep playing or quit
cout<<"Do you want to play again (y/n)? ";
cin>>playAgain;
}while(playAgain!='n');
// Display score.
cout<<"Your total score from fishing is:
"<<game.getScore()<<endl;
// Display feedback.
cout<<game.getFeedback();
// Keep this stuff at the end.
cout << endl;
system("pause");
return 0;
}
=========================================================================================

thanks !
In C++ program Fishing Game Simulation For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Eac...
12. Coin Toss Simulator Write a class named Coin. The Coin class should have the following field .A String named sideUp. The sideUp field will hold either "heads" or "tails" indicating the side of the coin that is facing up The Coin class should have the following methods .A no-arg constructor that randomly determines the side of the coin that is facing up (heads" or "tails") and initializes the aideUp field accordingly .A void method named toss that simulates the...
For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...
Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through 9 and put this in an array. Then these user numbers are compared to the random numbers the computer generated. The program will display both the computer random number and below the user selected numbers. The program will tell the user how many matches are made. If the user guesses all five you let them know they are the grand winner. Here is the...
question 2 in C programming please
PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to...
Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis With each guess... If the guess does not have an equal number of characters, tell the user...
Football Game Scores Write a C++ program that stores the following data about a football game in a structure: Field Name Description visit_team string (name of visiting team) home_score int visit_score int The program should read the number of games from a data file named “games.txt”, dynamically allocate an array of structures for the games using one structure for each game, and then read the information for each game from the same file (visiting team, home score, visiting team’s score)....
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
(C++) Hey guys we just went over loops and it got me
confused, it has me scrathcing my head for the past two days. I
would appreciate any help you guys have to offer. Few places I have
a hard time is get input and determine winner(cummulative
part).
Write a program that lets the user play the Rock, Paper,
Scissors game against the computer. The computer first chooses
randomly between rock, paper and scissors, but does not display its
choice....
In need of some help with a LCR C++ game. The code will run, but I need it to cycle through the turns automatically so that the only input from the user is the number of players. It's also showing the winner as the person with 0 chips which is incorrect and I can't figure out why. Any help is greatly appreciated as this is already late. Game rules: Develop a program that follows the rules of Left Center Right...