Skip to content

MR12 Report Lab

Dave Strus edited this page Jan 31, 2016 · 1 revision

LAB: Generating a Report

Our application can return a string of mutant descriptions, but that's not really the handiest way to get a readout of our mutants' stats. Let's make another method, called report, that prints all of the attributes for every mutant in a nice, readable format.

Let's say that our @mutants array contains these mutants:

Mutant 1

  • Real name: Doreen
  • Mutant name: Howldread
  • Power: Communes with animals

Mutant 2

  • Real name: Jon
  • Mutant name: Florabane
  • Power: De-weeds gardens in a flash

Mutant 3

  • Real name: Naomi
  • Mutant name: Talonkatana
  • Power: Toenails turn into actual swords

We'd like RosterApplication#report to print... well, something a lot like that actually.

How about this:

Mutant 1 ================================
* Real name: Doreen
* Mutant name: Howldread
* Power: Communes with animals

Mutant 2 ================================
* Real name: Jon
* Mutant name: Florabane
* Power: De-weeds gardens in a flash

Mutant 3 ================================
* Real name: Naomi
* Mutant name: Talonkatana
* Power: Toenails turn into actual swords
  • Implement RosterApplication#report
  • Replace the call to RosterApplication#mutant_descriptions in roster.rb with a call to report