GithubHelp home page GithubHelp logo

oo-my-pets's Introduction

My Pets

Objective

  1. Gain a deeper understanding of object relations.
  2. Build classes that produce objects that interact with one another through associations and behavior.

Instructions

This is a test-driven lab. Use the test file and test output to understand what is being asked of you as you follow the guidelines below.

Overview

You will be building an Owner, Dog, and Cat class. An Owner will know about all their pets, be able to buy a pet, change a pet's mood through walking or feeding it, and sell all of their pets (for when they move to that tiny NYC studio after college).

A Dog and a Cat are initialized with a name and an Owner object

Part I: Object Models

  • Define a Dog and Cat class that have the attributes required by the test suite. Keep in mind, some of the attributes should be readable and writable (i.e. attr_accessors), while others may need to be just setters (attr_writer) or just getters (attr_reader). The test suite will make this clear so pay attention to the test output.

Part II: Object Relations

  • An owner should be able to buy and sell a pet, which will change the pet's mood.

  • When an owner buys a new pet, the buy_cat/buy_dog methods take in an argument of a name. You must take that name and do the following:

    • Make a new instance of the appropriate pet, initializing it with that name and the owner who is purchasing it.
  • An owner should have the ability to walk all their dogs or feed all their cats, which will change the mood of all of their pets of that type to "happy".

These are just a few hints and guidelines to help you through this lab. This lab is extensive and challenging. Rely on the guides here, refer to the previous Code Along on object relations, and read the test output and test files. Never forget to ask a question on Learn if you are stuck. And remember, as a programmer, your job is to fix broken code! Broken code is the norm, the baseline, the starting point for all of the projects you will build. Embrace it!

View OO My Pets on Learn.co and start learning to code for free.

oo-my-pets's People

Contributors

ahimmelstoss avatar annjohn avatar arelenglish avatar bamsarker avatar curiositypaths avatar donnadieu avatar drakeltheryuujin avatar fislabstest avatar fs-lms-test-bot avatar imkaruna avatar jmburges avatar kthffmn avatar maxwellbenton avatar paulnicholsen27 avatar sarogers avatar sophiedebenedetto avatar victhevenot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oo-my-pets's Issues

Directions could use clarification

Hey there again.

These spec directions could use some editing/clarification. Under the Class methods, it includes initialize, but initialize is not a class method. This contradicts itself a couple lines down where it talks about initialize as an instance method. It would also be beneficial to line out which class methods are expected, the same way it is defined for instance methods.

Best,
Amanda

  Class methods
    keeps track of the owners that have been created
    can count how many owners have been created
    can reset the owners that have been created
    can initialize an owner
  instance methods
    #species
      initializes with a species
      can't change its species
    #say_species
      can say its species
    #name
      can have a name
    #pets
      is initialized with a pets attribute as a hash with 3 keys```

Rspec error

line 17 in spec/rspec/owner_spec.rb reads expect(Owner.count).to eq(0) instead of expect(Owner.all.count).to eq(0).

it returns the following error.
undefined method `count' for Owner:Class

No green light

I haven't gotten a green light for this despite submitting several days ago. Thanks!

Test not clear

the owner_spec.rb file's section on the #species instance method says
"initializes with a species" makes me think it should take an argument of species, it could be more clear (like it is explicitly said in all the new pet instantiations' moods) that the owner species should actually be set to human.

Warning from spec code

The specs call .to rails_error several times, as in: expect { dog.name = "Fido" }.to raise_error.
This gives the following warning:

WARNING: Using the `raise_error` matcher without providing a specific error or message risks false positives, since `raise_error` will match when
 Ruby raises a `NoMethodError`, `NameError` or `ArgumentError`, potentially allowing the expectation to pass without even executing the method yo
u are intending to call. Actual error raised was #<NoMethodError: undefined method `name=' for #<Dog:0x0000000256f7f0 @name="Daisy", @mood="nervo
us">
Did you mean?  name>. Instead consider providing a specific error class or message. This message can be suppressed by setting: `RSpec::Expectatio
ns.configuration.on_potential_false_positives = :nothing`. Called from /home/brianh/code/replicators/oo-my-pets-v-000/spec/dog_spec.rb:16:in `blo
ck (2 levels) in <top (required)>'.

I think we can find a different way to test these or at least a way to suppress these warnings.

@aturkewi

Tests not specific enough

Tests for #walk_dogs, #feed_cats, and #sell_pets allow for all cats, dogs, and pets to be changed, not just a particular owner's cats & dogs.

I would be extremely upset if my friend accidentally sold my dog when he moved after college.

buy_cat and buy_dog are misleading names

I spent a long time trying to change the owners of dog names before figuring out that this method is just supposed to make a new cat/dog. That was really frustrating.

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.