Advertisement
Guest User

FightingArena

a guest
Jun 21st, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. Fighting Arena
  2. Preparation
  3. Download the skeleton provided in Judge. Do not change the StartUp class or its namespace.
  4. Problem description
  5. Your task is to create an arena which stores gladiators by creating the classes described below.
  6. First, write a C# class Weapon with the following properties:
  7. Size: int
  8. Solidity: int
  9. Sharpness: int
  10. The class constructor should receive size, solidity and sharpness.
  11. Next, write a C# class Stat with the following properties:
  12. Strength: int
  13. Flexibility: int
  14. Agility: int
  15. Skills: int
  16. Intelligence: int
  17. The class constructor should receive strength, flexibility, agility, skills and intelligence.
  18. Next, write a C# class Gladiator with the following properties and methods:
  19. Name: string
  20. Stat: Stat
  21. Weapon: Weapon
  22. GetTotalPower(): int – return the sum of the stat properties plus the sum of the weapon properties.
  23. GetWeaponPower(): int - return the sum of the weapon properties.
  24. GetStatPower(): int - return the sum of the stat properties.
  25. The class constructor should receive name, stat and weapon and override ToString() in the following format:
  26. "[Gladiator name] - [Gladiator total power]"
  27. " Weapon Power: [Gladiator weapon power]"
  28. " Stat Power: [Gladiator stat power]"
  29. Write a C# class Arena that has gladiators (a collection which stores the class Gladiator).
  30. public class Arena
  31. {
  32. // TODO: implement this class
  33. }
  34. The class constructor should initialize the gladiators with a new instance of the collection. Implement the following features:
  35. Field gladiators – collection that holds added gladiators
  36. Property Name - string
  37. Method Add(Gladiator gladiator) – adds an gladiator to the arena.
  38. Method Remove(string name) – removes an gladiator by given name.
  39. Method GetGladitorWithHighestStatPower() – returns the Gladiator which has the highest stat.
  40. Method GetGladitorWithHighestWeaponPower() – returns the Gladiator which poses the weapon with the highest power.
  41. Method GetGladitorWithHighestTotalPower() – returns the Gladiator which has the highest total power.
  42. Getter Count – returns the number of stored heroes.
  43. Оverride ToString() – by the format below.
  44. "[Arena name] - [count of gladiators] gladiators are participating."
  45. Constraints
  46. The names of the gladiators will be always unique.
  47. The weapons and the stat properties of the gladiators will always be with positive values.
  48. The weapon power, stat power and total power of the gladiators will always be different.
  49. You will always have a gladiator with the highest stat, weapon and total power.
  50. Examples
  51. This is an example how the Arena class is intended to be used.
  52. Sample code usage
  53. //Creates arena
  54. Arena arena = new Arena("Armeec");
  55.  
  56. //Creates stats
  57. Stat firstGlariatorStat = new Stat(20, 25, 35, 14, 48);
  58. Stat secondGlariatorStat = new Stat(40, 40, 40, 40, 40);
  59. Stat thirdGlariatorStat = new Stat(20, 25, 35, 14, 48);
  60.  
  61. //Creates weapons
  62. Weapon firstGlariatorWeapon = new Weapon(5, 28, 100);
  63. Weapon secondGlariatorWeapon = new Weapon(5, 28, 100);
  64. Weapon thirdGlariatorWeapon = new Weapon(50, 50, 50);
  65.  
  66. //Creates gladiators
  67. Gladiator firstGladiator = new Gladiator("Stoyan", firstGlariatorStat, firstGlariatorWeapon);
  68. Gladiator secondGladiator = new Gladiator("Pesho", secondGlariatorStat, secondGlariatorWeapon);
  69. Gladiator thirdGladiator = new Gladiator("Gosho", thirdGlariatorStat, thirdGlariatorWeapon);
  70.  
  71. //Adds gladiators to arena
  72. arena.Add(firstGladiator);
  73. arena.Add(secondGladiator);
  74. arena.Add(thirdGladiator);
  75.  
  76. //Prints gladiators count at the arena
  77. Console.WriteLine(arena.Count);
  78.  
  79. //Gets strongest gladiator and print him
  80. Gladiator strongestGladiator = arena.GetGladitorWithHighestTotalPower();
  81. Console.WriteLine(strongestGladiator);
  82.  
  83. //Gets gladiator with the strongest weapon and print him
  84. Gladiator bestWeaponGladiator = arena.GetGladitorWithHighestWeaponPower();
  85. Console.WriteLine(bestWeaponGladiator);
  86.  
  87. //Gets gladiator with the strongest stat and print him
  88. Gladiator bestStatGladiator = arena.GetGladitorWithHighestStatPower();
  89. Console.WriteLine(bestStatGladiator);
  90.  
  91. //Removes gladiator
  92. arena.Remove("Gosho");
  93.  
  94. //Prints gladiators count at the arena
  95. Console.WriteLine(arena.Count);
  96.  
  97. //Prints the arena
  98. Console.WriteLine(arena);
  99. Submission
  100. Zip all the files in the project folder except bin and obj folders
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement