Coder Social home page Coder Social logo

hackbright-intro-classes's Introduction

Classes Exercise

Complete these in files in this repo called food.py, animals.py and plants.py, respectively.

For each of the following, create a class with at least the method describe and one other, storing any attributes necessary. Instantiate each of them with three different concrete examples. Consider what things you might want to know about each item that are common to all things in that category (e.g. every food item has a recipe, but the recipe is different for each item).

Food

Required method: print_recipe()

I should be able to create and use a food item as follows

pb_apple = new Food("Cut apples.\nPlace apples and some peanut butter on platter with a knife.")
pb_apple.print_recipe()

and get the following output:

Recipe
======
Cut apples.
Place apples and some peanut butter on platter with a knife.

Note: You can require more parameters to the ___init___ method for your second method if desired.

Second Method

Up to you!

Instantiate

Instantiate your class with 3 different sets of values, calling each method on each of them. (hint: what structure do you know of that's good for storing a known number of things? How can you perform the same set of actions on each item in turn without writing repetitive code?)

Animals

Required method: has_fur()

should return a boolean

Second Method

Up to you!

Instantiate

Instantiate your class with 3 different sets of values, calling each method on each of them.

Plants

Required method: set_is_flowering(bool)

should take a boolean indicating whether the plant is currently flowering and update an attribute in the class accordingly

Second Method

Up to you!

Instantiate

Instantiate your class with 3 different sets of values, calling each method on each of them.

hackbright-intro-classes's People

Contributors

christinajensen avatar salogel42 avatar

Watchers

 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.