Week 8 Test 1.rtf - require\/input_functions ASK_YOUR_TUTOR_FOR_THIS = 7451 class Animal attr_accessor:id:species:cage_number:name end def read_animals

Week 8 Test 1.rtf - require/input_functions...

This preview shows page 1 - 3 out of 3 pages.

require './input_functions' ASK_YOUR_TUTOR_FOR_THIS = 7451 class Animal attr_accessor :id, :species, :cage_number, :name end def read_animals() count = 3 animals = Array.new count.times do animal = read_animal() animals << animal end animals end def read_animal() animal = Animal.new animal.id = read_integer("Enter Animal ID!") animal.species = read_string("Enter Animal Species!")
animal.cage_number = read_integer("Enter Animal Cage Number!") animal.name = read_string("Enter Animal Name!") animal end def display_animals(animals) animals.each do | animal | display_animal(animal) end end def display_animal(animal)

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture