public class Player
{
private string Name;
private int Health = 100;
private int Damage;
public Player(string name, int health, int damage)
{
name = Name;
health = Health;
damage = Damage;
}
}
public class Enemy
{
public void enemyTakeDamage()
{
int takenDamage;
}
private string Name;
private int Health = 100;
private int Damage;
public string enemyMessages;
public Enemy(string name, int health, int damage)
{
name = Name;
health = Health;
damage = Damage;
}
}
class Program
{
static void Main(string[] args)
{
bool dead;
Player P1 = new Player("Zach", 100, 20);
}
}
So I initialized an object called P1 with the name of "zach" and the hp of 100 and damage of 20, I cannot access those 3 variables elsewhere. These arent the private variables in the player class, Im talking about the ones in the class that are intialized by doing :
public Player(string name, int health, int damage)
I thought I can just call P1.health anywhere I wanted if it is public? any help is appreciated and this is my first text based console game I'm working on so other input is also appreciated.