Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. namespace FightingArena
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6.  
  7. public class Gladiator
  8. {
  9. public Gladiator(string name, Stat stat, Weapon weapon)
  10. {
  11. this.Name = name;
  12. this.Stat = stat;
  13. this.Weapon = weapon;
  14. }
  15. public string Name { get; set; }
  16. public Stat Stat { get; set; }
  17. public Weapon Weapon { get; set; }
  18.  
  19. // return the sum of the weapon properties.
  20. public int GetWeaponPower()
  21. {
  22. int power = this.Weapon.Sharpness + this.Weapon.Size + this.Weapon.Solidity;
  23. return power;
  24. }
  25.  
  26. // return the sum of the stat properties.
  27. public int GetStatPower()
  28. {
  29. int power = this.Stat.Agility + this.Stat.Flexibility + this.Stat.Intelligence + this.Stat.Skills;
  30. return power;
  31. }
  32.  
  33. // return the sum of the stat properties plus the sum of the weapon properties
  34. public int GetTotalPower()
  35. {
  36. return GetWeaponPower() + GetStatPower();
  37. }
  38.  
  39. public override string ToString()
  40. {
  41. var sb = new StringBuilder();
  42. sb.AppendLine($"{this.Name} - {this.GetTotalPower()}");
  43. sb.AppendLine($" Weapon Power: {this.GetWeaponPower()}");
  44. sb.AppendLine($" Stat Power: {this.GetStatPower()}");
  45.  
  46. return sb.ToString().Trim();
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement