Giter VIP home page Giter VIP logo

oo-python-freebie-tracker's Introduction

Phase 3 Mock Code Challenge: Freebie Tracker

Introduction

For this assignment, we'll be working with a freebie domain.

As developers, when you attend hackathons, you'll realize they hand out a lot of free items (informally called freebies, or swag)! Let's make an app for developers that keeps track of all the freebies they obtain.

We have three models: Company, Dev, and Freebie

For our purposes, a Company has many Freebies, a Dev has many Freebies, and a Freebie belongs to a Dev and to a Company.

Company - Dev is a many to many relationship.

Note: You should draw your domain on paper or on a whiteboard before you start coding. Remember to identify a single source of truth for your data.

Instructions

Build out all of the methods listed in the deliverables. The methods are listed in a suggested order, but you can feel free to tackle the ones you think are easiest. Be careful: some of the later methods rely on earlier ones.

Remember! This mock code challenge does not have tests. You cannot run pytest and you cannot run learn test. You'll need to create your own sample instances so that you can try out your code on your own. Make sure your relationships and methods work in the console before submitting.

We've provided you with a tool that you can use to test your code. To use it, run python debug.py from the command line. This will start an ipdb session with your classes defined. You can test out the methods that you write here.

Writing error-free code is more important than completing all of the deliverables listed- prioritize writing methods that work over writing more methods that don't work. You should test your code in the console as you write.

Similarly, messy code that works is better than clean code that doesn't. First, prioritize getting things working. Then, if there is time at the end, refactor your code to adhere to best practices.

Before you submit! Save and run your code to verify that it works as you expect. If you have any methods that are not working yet, feel free to leave comments describing your progress.


Deliverables

Write the following functionality in the classes in the files provided. Feel free to build out any helper methods if needed.

  • A Company has a name that's a string & founding year that is an integer.

  • A Dev has a name that's a string.

  • A Freebie belongs to a Dev, and a Freebie also belongs to a Company.

  • The freebies model should also have:

    • An item_name column that stores a string.
    • A value column that stores an integer.

After you've set up your freebies, work on building out the following deliverables.

Freebie

  • Freebie.dev returns the Dev instance for this Freebie.
  • Freebie.company returns the Company instance for this Freebie.

Company

  • Company.freebies returns a collection of all the freebies for the Company.
  • Company.devs returns a collection of all the devs who collected freebies from the company.

Dev

  • Dev.freebies returns a collection of all the freebies that the Dev has collected.
  • Dev.companiesreturns a collection of all the companies that the Dev has collected freebies from.

Use python debug.py and check that these methods work before proceeding.

Aggregate Methods

Freebie

  • Freebie.print_details()should return a string formatted as follows: {dev name} owns a {freebie item_name} from {company name}.

Company

  • Company.give_freebie(dev, item_name, value) takes a dev (an instance of the Dev class), an item_name (string), and a value as arguments, and creates a new Freebie instance associated with this company and the given dev.
  • Class method Company.oldest_company()returns the Company instance with the earliest founding year.

Dev

  • Dev.received_one(item_name) accepts an item_name (string) and returns True if any of the freebies associated with the dev has that item_name, otherwise returns False.
  • Dev.give_away(dev, freebie) accepts a Dev instance and a Freebie instance, changes the freebie's dev to be the given dev; your code should only make the change if the freebie belongs to the dev who's giving it away

oo-python-freebie-tracker's People

Contributors

professor-ben avatar adam-larosa avatar jlboba 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.