Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Latest commit

 

History

History
52 lines (36 loc) · 2.27 KB

EightiesKids6.md

File metadata and controls

52 lines (36 loc) · 2.27 KB

Back to README

Day #6: 80's Kids #6: Rock 'Em, Sock 'Em Robots

Description:

You and your friends have been battling it out with your Rock 'Em, Sock 'Em robots, but things have gotten a little boring. You've each decided to add some amazing new features to your robot and automate them to battle to the death.

Each robot will be represented by an object. You will be given two robot objects, and an object of battle tactics and how much damage they produce. Each robot will have a name, hit points, speed, and then a list of battle tacitcs they are to perform in order. Whichever robot has the best speed, will attack first with one battle tactic.

Your job is to decide who wins.

Example:

robot1.getName() => "Rocky"
robot1.getHealth() => 100
robot1.getSpeed() => 20
robot1.getTactics() => ["punch", "punch", "laser", "missle"]

robot2.getName() => "Missile Bob"
robot2.getHealth() => 100
robot2.getSpeed() => 21
robot2.getTactics() => ["missle", "missle", "missle", "missle"]

tactics = {
    "punch" => 20,
    "laser" => 30,
    "missile" => 35
}

fight(Robot robot1, Robot robot2, Map tactics) -> "Missile Bob has won the fight."

robot2 uses the first tactic, "missile" because he has the most speed. This reduces robot1's health by 35. Now robot1 uses a punch, and so on.

Rules

  • A robot with the most speed attacks first. If they are tied, the first robot passed in attacks first.
  • Robots alternate turns attacking. Tactics are used in order.
  • A fight is over when a robot has 0 or less health or both robots have run out of tactics.
  • A robot who has no tactics left does no more damage, but the other robot may use the rest of his tactics.
  • If both robots run out of tactics, whoever has the most health wins. Return the message "{Name} has won the fight."
  • If both robots run out of tactics and are tied for health, the fight is a draw. Return "The fight was a draw."

To Java warriors

Robot class is immutable.