Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the scaffold code provided for this task. Complete the following code requirements in the Ruby language for the file bird.rb. Your final code must

image text in transcribedUse the scaffold code provided for this task.

Complete the following code requirements in the Ruby language for the file bird.rb.

Your final code must be structured and run.

You must create a record (using Ruby classes) for a bird. A bird has the following attributes: an id (integer), a location caught (string), a species (string), and a cage number (integer).

Write a function called read_bird() that reads from the terminal values for each of the fields in a Bird record and returns the completed record.

Write a procedure called print_bird(bird) that takes a bird record and writes each of the fields to the terminal with a description for the field as well as the field value.

Write a function called read_birds() that calls your read_bird() and returns an array of Birds.

Write a procedure called print_birds(birds) that calls your print_bird(bird) procedure for each bird in the array.

Write a procedure called print_birds(birds) that calls your print_bird(bird) procedure for each bird in the array.

Bird.rb -

require './input_functions'

# Complete the code below

# Use input_functions to read the data from the user

def read_bird()

end

def read_birds()

end

def print_bird(bird)

end

def print_birds(birds)

end

def main()

birds = read_birds()

print_birds(birds)

end

main()

Use the scaffold code provided for this task. Camplete the following code requirements in the Ruby language far the file bird. rb. Your final code must be structured and run. Requirements: You must create a record (using Auby classes) for a bird. A bird has the fallowing attributes: an id (integer), a location caught (string), a species (stringl, and a cage number (integer). Write a function called read_bird(I) that reads from the terminal values for esch af the fieids in a Bird record and returns the completed record. Write a procedure called print_bird(bird) that takes a bird record and writes esch of the fields to the terminal with a description for the field as well as the field value. Write a function called read_birds(0 that calls your read_birdi) and returns an array af Birds. Write a procedure called print_birds/birds) that cals your print_bird(bird) procedure for each bird in the array. Write a procedure called print_birds/birds) that cals your print_bird(bird) procedure for each bird in the array. Use the folowing test data: Your code should run as follows (with the test data above)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Prove that a 2 2 matrix A is reducible if and only if a12a21 = 0.

Answered: 1 week ago