Git Product home page Git Product logo

p3-oo-many-to-many-lab's Introduction

Many-to-many Object Relationships Lab

Learning Goals

  • Create a Many-to-many relationship using an intermediary class.
  • Write aggregate methods.

Key Vocab

  • Class: a bundle of data and functionality. Can be copied and modified to accomplish a wide variety of programming tasks.
  • Object: the more common name for an instance. The two can usually be used interchangeably.
  • Object-Oriented Programming: programming that is oriented around data (made mobile and changeable in objects) rather than functionality. Python is an object-oriented programming language.
  • Function: a series of steps that create, transform, and move data.
  • Method: a function that is defined inside of a class.

Introduction

In this lab we will implement a one-to-many relationship between a Author, Book, and Contract.

This is a test-driven lab. Run pipenv install to create your virtual environment and pipenv shell to enter the virtual environment. Then run pytest -x to run your tests. Use these instructions and pytest's error messages to complete your work in the lib/ folder.


Instructions

Create a Book class that has the following attributes: title (string)

Create an Author class that has the following attributes: name (string)

Create a Contract class that has the following properties: author (Author object), book (Book object), date (string), and royalties (int).

All classes should also keep track of all members using a class variable.

  • The author property should be an instance of the Author class, while the book property should be an instance of the Book class. The date property should be a string that represents the date when the contract was signed, while the royalties property should be a number that represents the percentage of royalties that the author will receive for the book.
    • All setters should raise Exception upon failure.

The Author class should have the following methods:

  • contracts(self): This method should return a list of related contracts.
  • books(self): This method should return a list of related books using the Contract class as an intermediary.
  • sign_contract(book, date, royalties): This method should create and return a new Contract object between the author and the specified book with the specified date and royalties
  • total_royalties(): This method should return the total amount of royalties that the author has earned from all of their contracts.

The Contract class should have the following methods:

  • A class method contracts_by_date(cls, date): This method should return all contracts that have the same date as the date passed into the method.

Resources

p3-oo-many-to-many-lab's People

Contributors

linda-seiter avatar lizbur10 avatar pgill97 avatar professor-ben avatar

Watchers

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

p3-oo-many-to-many-lab's Issues

Deliverable issue

Canvas Link

https://learning.flatironschool.com/courses/6444/assignments/244094?module_item_id=574893

Concern

On canvas it says this:
The Contract class should have the following methods:

A class method contracts_by_date(cls, date): This method should return all contracts that have the same date as the date passed into the method.

The test however tells you to pass 0 arguments and to sort the contracts by date.

Additional Context

No response

Suggested Changes

You can either change the instructions on canvas or change the test itself.

Contradicting final deliverable

Canvas Link

https://learning.flatironschool.com/courses/6559/assignments/242929?module_item_id=571576

Concern

Lines 67 and 68 of the README.md are asking for a class method that returns every contract that was produced on the same date. However, the test is looking for a function that sorts all of the contracts by date. Also, if you put in the params that the README.md asks for, you will get a TypeError as the tests believes you only need 1 required positional argument.

Additional Context

No response

Suggested Changes

I noticed other issues have been raised about this lab for months, please update either the README or the tests to reflect what is desired.

Confusing last deliverable

Canvas Link

https://learning.flatironschool.com/courses/6435/assignments/242503?module_item_id=570054

Concern

Last ReadMe and pytest are not asking for the same thing. One wants a sorted list and the other just wants data compared.

Additional Context

if you put all soultion code in except for last attribute in Contracts contracts_by_date(cls, date) you will see. also date param is not included or needed for pytest solution.

Suggested Changes

just very annoying and this lab was a little dense compared to other labs and i have heard alot of complaints from my cohort so just thought i would bring it to somebodies attention for the future i know you guys are busy.

Phase 3 - Many-to-many Object Relationships Lab

Canvas Link

https://learning.flatironschool.com/courses/6568/assignments/244959?module_item_id=577038

Concern

In this lab, one of the things I needed to implement was the contracts_by_date class method, and the testcase for this class method described its test as """Test Contract class has method contracts_by_date() that sorts all contracts by date""". However, contracts_by_date() takes a date as its argument and returns a list of contracts made in the date. Since all contracts in the return value were on same date, how could I sort the list by date?

Additional Context

No response

Suggested Changes

I think the test should ask me to sort the return value, a list, by author's name, book's title or royalties.

Canvas asks you to filter by date but pytest is testing for a sorted list

Canvas Link

https://learning.flatironschool.com/courses/6192/assignments/240664?module_item_id=565714

Concern

Canvas says this:

A class method contracts_by_date(cls, date): This method should return all contracts that have the same date as the date passed into the method.

And pytest says this: """Test Contract class has method contracts_by_date() that sorts all contracts by date"""

Additional Context

No response

Suggested Changes

Doesn't matter I just figured you would want to know. It confused me for a bit until I looked at the solution

Incongruity between Instructions and Test

Canvas Link

https://learning.flatironschool.com/courses/6200/assignments/240673?module_item_id=565718

Concern

The final check for the test asks for a method contracts_by_date() that SORTS all contracts by date, while the instructions ask for a method of the same name that returns all contracts that HAVE THE SAME date as the date passed into the method.

Additional Context

No response

Suggested Changes

Change the test to reflect the instructions or vice versa.

Lab is asking you to code something different than the test/solution is

Canvas Link

https://learning.flatironschool.com/courses/6192/assignments/240664?module_item_id=565714

Concern

The lab in canvas wants you to write the method 'contracts_by_date' to return all the contracts that were on the date that it passses in as a parameter. The actual test is testing if all the contracts are sorted by date (not returning contracts on a specific date.

Additional Context

Canvas lab wants you to code this:
@classmethod
def contracts_by_date(cls, date):
return [contract for contract in cls.all if contract.date == date].

While the test file is testing for this code:
def contracts_by_date(cls):
return sorted(cls.all, key=lambda contract: contract.date)

Suggested Changes

I just figured you might want to know

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.