Giter Site home page Giter Site logo

oo-my-pets-v-000'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, Fish, Dog, and Cat class. An owner will know about all its pets, be able to buy a pet, set the name of a pet (which the pet can't change, because that would be weird), change a pet's mood through walking, feeding, or playing with it, and sell all of its pets (for when it moves to that tiny NYC studio after college).

Part I: Object Models

  • Define a Dog, Fish 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 know about its pets! Instances of the Owner class should be initialized with an @pets variable, set equal to the following hash: {fishes: [], cats: [], dogs: []}
  • An owner should be able to buy and sell pets, and therefore alter the @pets hash. You will therefore need a setter and a getter method (attr_accessor) for pets.
  • When an owner buys a new pet, the buy_``cat/dog/fish method takes 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.
    • Associate that new pet instance to the owner by adding it to the appropriate array-value of the @pets hash stored in the pets attr_accessor.
  • When an owner plays with a cat or feeds a fish or walks a dog, that pet will get happier. Remember that the pets method stores all of an owners pets. The @pets hash stored in that method is full of instances of the Cat/Dog/Fish class. That means you can call Cat/Dog/Fish instance methods (such as .mood=) on those pets.

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 My Pets on Learn.co and start learning to code for free.

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

oo-my-pets-v-000's People

Contributors

kthffmn avatar ahimmelstoss avatar sophiedebenedetto avatar annjohn avatar arelenglish avatar jmburges avatar fislabstest avatar aml7733 avatar fs-lms-test-bot avatar imkaruna avatar sarogers avatar victhevenot avatar

Watchers

James Cloos avatar  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.