The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
Loading...
Searching...
No Matches
User Class Reference

Represents a player in the game with name and score tracking. More...

#include <user.hpp>

Public Member Functions

int get_round () const
 Gets the current round number.
 
const std::string & get_user_name () const
 Gets the user's name.
 
int get_user_score () const
 Gets the current score of the user.
 
void increment_score ()
 Increments the user's score by 1.
 
void reset_score ()
 Resets the user's score to 0.
 
void set_round (int _round)
 Sets the current round number.
 
void set_user_name (const std::string &name)
 Sets the user's name.
 
void set_user_score (int _score)
 Sets the user's score to a specific value.
 
 User (const std::string &name="Player")
 Constructor for User class.
 

Private Attributes

std::string name
 
int round
 
int score
 

Detailed Description

Represents a player in the game with name and score tracking.

This class manages player information including their name, score, and round tracking for story mode.

Constructor & Destructor Documentation

◆ User()

User::User ( const std::string & name = "Player")

Constructor for User class.

Parameters
nameThe name of the user (defaults to "Player")

Initializes a user with the given name and sets score and round to 0

Parameters
nameThe name of the user

Member Function Documentation

◆ get_round()

int User::get_round ( ) const

Gets the current round number.

Returns
The current round number

◆ get_user_name()

const std::string & User::get_user_name ( ) const

Gets the user's name.

Returns
The user's name as a constant reference
const std::string& The user's name as a constant reference

◆ get_user_score()

int User::get_user_score ( ) const

Gets the current score of the user.

Returns
The user's current score
int The user's current score

◆ increment_score()

void User::increment_score ( )

Increments the user's score by 1.

Called when the user wins a round or scores a point

◆ reset_score()

void User::reset_score ( )

Resets the user's score to 0.

Used when the game is over or when a reset is needed

Used when the game is over or when a score reset is needed

◆ set_round()

void User::set_round ( int _round)

Sets the current round number.

Parameters
_roundThe round number to set

◆ set_user_name()

void User::set_user_name ( const std::string & newName)

Sets the user's name.

Parameters
nameThe new name for the user
newNameThe new name for the user

◆ set_user_score()

void User::set_user_score ( int _score)

Sets the user's score to a specific value.

Parameters
_scoreThe new score to set

Member Data Documentation

◆ name

std::string User::name
private

The user's name

◆ round

int User::round
private

The current round number (used for story mode)

◆ score

int User::score
private

The user's current score


The documentation for this class was generated from the following files: