Strictly speaking, the answer is no. It's not correct.
Did you try compiling this (with necessary #includes and main function)?
Line 17-18: You can't break the quotes like that over multiple lines (well you can, but just don't). Bring the " down to line 18.
But... syntax aside, we have no idea what "correct" means.
***************************************
LETS GET STARTED !!!!
***************************************
ENTER PLAYER 1 NAME :- John
ENTER PLAYER 2 NAME :- Connor
***************************************
Hello!! John and Connor
welcome to PAIRS!!
**********************************************
NAME:- John Score:-
**********************************************
NAME:- Connor Score:-
It look OK. I assume you are going to fill in "score" with something?
But the name of your class is odd. You call it player, but you use this class to fill in two strings. You don't use the name or score member variables of your class.
getName() might as well just be a function defined outside of any class, because the class is not used in any meaningful way.
Focus on the actual logic of the program before focusing on eye-candy like clearing the screen and "**************".
its a game of cards but its not a normal game of cards its a card game called pairs in their game
-deck has 55 cards(1(1),2,(2),3(3)....10(10))
-the whole point of the game is not to reach the target score
-score
for a two player game the score is 31
-how do the score go up
in the game there are two options either hit or fold
-hit , this means you can draw a card from the deck but if you draw and get a pair that cards number will add up to your score and the hand gets discarded and they get dealt a new card this happens when ever a round ends.
-a round ends when a player either decides to fold or gets a pair
-a pair, a pair is when you get the same number when you hit and draw a card
example :- [10] [10]
-fold, this is so if you have a higher value number such as [10] there is a high chance of getting a number [10] so the player can fold and get the lowest card in the other players hand and then again the hand gets discarded and the card he took from folding will be added to the score
-if the deck runs out the discarded has to be used again by burning the top 5 cards of the discarded deck
- game ends when a player reaches a target score so this has to be checked every round
so to make this game i should use three classes,
class class
class player
class pairs and this includes the main()
and in the uml diagrams i did watching an example they gave for an other game,
Player
-playerName : string
-playerScore : int
+Player(name:string)
+~Player()
+ getName():string
+ getScore(): int
+ updateScore():void
menueOption(option:int) : int
getNoOfPlayers(number:int) :int //this is an additional task you can add more players to
play
stringGetName(name:string):string
getOption(option:char):int
playAgain(answer:char):bool
checkLoser(): bool
(the other player is not an AI its me playing vs me for the moment :) )
i can post the code of what i have done to if you want . and im sorry if i have made any silly mistakes cus this is my first major project as in ive never made anything like this,feel free to share your ideas :)
Player
-playerName : string
-playerScore : int
+Player(name:string)
+~Player()
+ getName():string
+ getScore(): int
+ updateScore():void
Yes, so as I suspected, you are using the Player class incorrectly.
The player class should have member variables "playerName" and "playerScore".
It should have a constructor that takes in a string for the name (presumably, starting the score at 0).
And then also has getters and setters, and an updateScore() function, although I'm not sure what the function of this is, seeing as it apparently doesn't take in any parameters. Maybe it should take in an int?
thank you Ganado, i get where i have went wrong but i dont know how to use thes to get the player inputs in the main im sorry if its a bad qustion :) the reason me doing it that way is thats the only way i knew i could use them to get an input can you explain me how can i use this in my programme?
int main()
{
string name;
cout << "Enter player name: ";
getline("cin, name);
// Now you can create your player
Player player1(name);
cout << "The player name: " << player1.getName() << '\n';
}