Giter Site home page Giter Site logo

afternoon_zoo_2105's Introduction

Afternoon Zoo

Instructions

  • Fork this Repository
  • Clone YOUR fork
  • Compete the activity below
  • Push your solution to your fork
  • Submit a pull request from your repository to the turingschool-examples repository
  • Make sure to put your name in your PR!

Iteration 1

Starting with the existing tests, and then use TDD to create an Animal class that responds to the following interaction pattern:

(Where you see something like #<Animal:0x00007fccd30375f8...>, this is shorthand for a full animal object with that object identifier - we have replaced any attributes with ... for readability.)

Notes: There are seven days in a week.

pry(main)> require './lib/animal'
#=> true

pry(main)> animal_1 = Animal.new("Sea Otter", 10, 25)
#=> #<Car:0x00007fa53b9ca0a8...>

pry(main)> animal_1.kind
#=> "Sea Otter"

pry(main)> animal_1.weight
#=> "10 pounds"

pry(main)> animal_1.age
#=> "25 weeks"

pry(main)> animal_1.age_in_days
#=> 175

pry(main)> animal_1.feed!(2)

pry(main)> animal_1.weight
#=> "12 pounds"

pry(main)> animal_1.feed!(1)

pry(main)> animal_1.weight
#=> "13 pounds"

Iteration 2

Use TDD to create a Zoo class that responds to the following interaction pattern:

(Where you see something like #<Zoo:0x00007fccd30375f8...>, this is shorthand for a full zoo object with that object identifier - we have replaced any attributes with ... for readability.)

pry(main)> require './lib/animal'
#=> true

pry(main)> require './lib/zoo'
#=> true

pry(main)> zoo = Zoo.new("Bronx Zoo", "2300 Southern Blvd", "Bronx", "NY", "10460")
#=> #<Zoo:0x00007fccd30375f8...>

pry(main)> zoo.street
#=> "2300 Southern Blvd"

pry(main)> zoo.city
#=> "Bronx"

pry(main)> zoo.state
#=> "NY"

pry(main)> zoo.zip_code
#=> "10460"

pry(main)> zoo.address
#=> "2300 Southern Blvd Bronx, NY 10460"

pry(main)> zoo.inventory
#=> []

pry(main)> zoo.animal_count
#=> 0

pry(main)> animal_1 = Animal.new("Sea Otter", 10, 25)
#=> #<Car:0x00007fa53b9ca0a8...>

pry(main)> animal_2 = Animal.new("Red Panda", 5, 70)
#=> #<Car:0x00007fccd2985f48...>

pry(main)> zoo.add_animal(animal_1)

pry(main)> zoo.add_animal(animal_2)

pry(main)> zoo.inventory
#=> [#<Animal:0x00007fa53b9ca0a8...>, #<Animal:0x00007fccd2985f48...>]

pry(main)> zoo.animal_count
#=> 2

Iteration 3

Use TDD to up date your Zoo class so that it responds to the following interaction pattern:

Note: animals_older_than() is going by weeks old.

pry(main)> require './lib/animal'
#=> true

pry(main)> require './lib/zoo'
#=> true

pry(main)> zoo = Zoo.new("Bronx Zoo", "2300 Southern Blvd", "Bronx", "NY", "10460")
#=> #<Zoo:0x00007fccd30375f8...>

pry(main)> animal_1 = Animal.new("Sea Otter", 10, 25)
#=> #<Animal:0x00007fccd29b5720...>

pry(main)> animal_2 = Animal.new("Red Panda", 5, 70)
#=> #<Animal:0x00007fccd2985f48...>

pry(main)> animal_3 = Animal.new("Capybara", 100, 150)
#=> #<Animal:0x00007fccd383c2d0...>

pry(main)> animal_4 = Animal.new("Dolphin", 150, 200)
#=> #<Animal:0x00007fccd297dc30...>

pry(main)> zoo.add_animal(animal_1)

pry(main)> zoo.add_animal(animal_2)

pry(main)> zoo.add_animal(animal_3)

pry(main)> zoo.add_animal(animal_4)

pry(main)> zoo.animals_older_than(250)
#=> []

pry(main)> zoo.animals_older_than(100)
#=> [#<Animal:0x00007fccd383c2d0...>, #<Animal:0x00007fccd297dc30...>]

pry(main)> zoo.animals_older_than(10)
#=> [#<Animal:0x00007fccd29b5720...>, #<Animal:0x00007fccd2985f48...>, #<Animal:0x00007fccd383c2d0...>, #<Animal:0x00007fccd297dc30...>]

pry(main)> zoo.total_weight_of_animals
#=> 265

pry(main)> zoo.details
#=> {"total_weight" => 265, "street_address" => "2300 Southern Blvd"}

Iteration 4

Use TDD to update your Zoo class so that it responds to the following interaction pattern:

Note:

  • Sorted by weight should be from heaviest to lightest.
  • Animal hash generates a hash where the key is the first letter of the kind of animal and the value is an array of animals that start with that letter of the alphabet
pry(main)> require './lib/animal'
#=> true

pry(main)> require './lib/zoo'
#=> true

pry(main)> zoo = Zoo.new("Bronx Zoo", "2300 Southern Blvd", "Bronx", "NY", "10460")
#=> #<Zoo:0x00007fccd30375f8...>

pry(main)> animal_1 = Animal.new("Sea Otter", 10, 25)
#=> #<Animal:0x00007fccd29b5720...>

pry(main)> animal_2 = Animal.new("Red Panda", 5, 70)
#=> #<Animal:0x00007fccd2985f48...>

pry(main)> animal_3 = Animal.new("Capybara", 100, 150)
#=> #<Animal:0x00007fccd383c2d0...>

pry(main)> animal_4 = Animal.new("Dolphin", 150, 200)
#=> #<Animal:0x00007fccd297dc30...>

pry(main)> zoo.add_animal(animal_1)

pry(main)> zoo.add_animal(animal_2)

pry(main)> zoo.add_animal(animal_3)

pry(main)> zoo.add_animal(animal_4)

zoo.animals_sorted_by_weight
#=> [#<Animal:0x00007fccd297dc30...>,#<Animal:0x00007fccd383c2d0...>,#<Animal:0x00007fccd2985f48...,#<Animal:0x00007fccd29b5720...>]

pry(main)> animal_5 = Animal.new("Dog", 65, 200)
#=> #<Animal:0x00007fccd297dc30...>

pry(main)> zoo.add_animal(animal_5)
#=> #<Animal:0x00007f23d297dc30...>

pry(main)> zoo.animal_hash
#=> {
"C" => [#<Animal:0x00007fccd383c2d0...>],
"D" => [#<Animal:0x00007f23d297dc30...>, #<Animal:0x00007fccd297dc30...>],
"R" => [#<Animal:0x00007fccd2985f48...>],
"S" => [#<Animal:0x00007fccd29b5720...>]
}

afternoon_zoo_2105's People

Contributors

larroyo1 avatar mikedao avatar

Stargazers

salah alhashmi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.