Coder Social home page Coder Social logo

ruby-oo-object-relationships-my-pets's Introduction

Object Relationships: My Pets Lab

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".

Owner, Dogs and Cats

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 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!

ruby-oo-object-relationships-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 ihollander avatar imkaruna avatar jmburges avatar kthffmn avatar lizbur10 avatar maxwellbenton avatar paulnicholsen27 avatar sarogers avatar sophiedebenedetto avatar timothylevi avatar victhevenot avatar

Watchers

 avatar  avatar  avatar

ruby-oo-object-relationships-my-pets's Issues

Associations "knows about its dogs/cats"

This tests to make sure the cats/dogs are returned in a specific order, however other methods work and return in a different order. My array found all items but returned in a different order.

rename method reset_all

owner.rb

  1. Owner Class methods .reset_all can reset the owners that have been created
    Failure/Error: expect(Owner.count).to eq(0)

    expected: 0
    got: 10

This test says reset the owners that have been created but we are actually resetting the count of owners

faulty test logic

Thanks for raising this issue! Future learners thank you for your diligence. In
order to help the curriculum team address the problem, please use this template
to submit your feedback. We'll work on addressing the issue as soon as we can.

Please fill out as much of the information below as you can (it's ok if you
don't fill out every section). The more context we have, the easier it will be
to fix your issue!

Note: you should only raise issues related to the contents of this lesson.
If you have questions about your code or need help troubleshooting, reach out to
an instructor/your peers.


Link to Canvas

https://learning.flatironschool.com/courses/1879/assignments/125330?module_item_id=259150

Describe the bug

on test "#buy cat" the test logic is this: expect(@owner.cats[1].name).to eq("Whiskers")
what the test does not realize is that I has you purchase 3 animals so the explicit index of 1 returning false does not mean that the code is incorrect. it could simply mean it is not in the order the test was hardcoded to receive the information. I suggest an iterator instead. Test if there is an instance that include?'s the name of whiskers that belongs to @owner.

What OS are you using?

  • OS X
  • WSL
  • Linux

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.