Skip to content

Instantly share code, notes, and snippets.

@GigaOrts
Forked from HolyMonkey/medium8-1-4.cs
Last active April 15, 2024 22:16
Show Gist options
  • Save GigaOrts/c7b2c1b1d23368f8e7a2cea0741aeb66 to your computer and use it in GitHub Desktop.
Save GigaOrts/c7b2c1b1d23368f8e7a2cea0741aeb66 to your computer and use it in GitHub Desktop.
class Player
{
private readonly Movement _movement;
private readonly Weapon _weapon;
public Player(string name, int age, Movement movement, Weapon weapon)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException($"\"{nameof(name)}\" не может быть пустым или содержать только пробел.", nameof(name));
}
if (age <= 0)
{
throw new ArgumentOutOfRangeException(nameof(age));
}
if (movement is null)
{
throw new ArgumentNullException(nameof(movement));
}
if (weapon is null)
{
throw new ArgumentNullException(nameof(weapon));
}
Name = name;
Age = age;
_movement = movement;
_weapon = weapon;
}
public string Name { get; private set; }
public int Age { get; private set; }
}
class Movement
{
public Movement(float directionY, float directionX, float speed)
{
DirectionY = directionY;
DirectionX = directionX;
Speed = speed;
}
public float DirectionX { get; private set; }
public float DirectionY { get; private set; }
public float Speed { get; private set; }
public void Move()
{
//Do move
}
}
class Weapon
{
public Weapon(float cooldown, int damage)
{
if(cooldown <= 0)
{
throw new ArgumentOutOfRangeException(nameof(cooldown));
}
if (damage <= 0)
{
throw new ArgumentOutOfRangeException(nameof(cooldown));
}
Cooldown = cooldown;
Damage = damage;
}
public float Cooldown { get; }
public int Damage { get; }
public void Attack()
{
//attack
}
public bool IsReloading()
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment