GithubHelp home page GithubHelp logo

budget-tool-oo's Introduction

TRANSACTION TRACKER OO

Run bundle install and ruby tools/console.rb in your terminal to start this program

For this exercise, you will be creating a program to track transactions between users and store locations. For our purposes, a Customer has many Transactions, a Location has many Transactions, and Transactions belong to both Customer and Location.

Deliverables

The below are the methods that must be present on your models. Feel free to build out any helper methods if needed.

Basic Class Methods and Properties

Build the following methods on the Customer class

A customer is initialized with a name as a string. A name cannot be changed after it is initialized.

  • Customer#name
    • Returns the name of the Customer as a string
  • Customer.all
    • Returns an array of all Customer instances

Build the following methods on the Transaction class

An transaction is initialized with an customer as a Customer object, a location as a Location object, and amount as a number. A transaction cannot change its customer or location after it is has been initialized.

  • Transaction.all
    • Returns an array of all Transaction instances
  • Transaction#customer
    • Returns the customer for that given Transaction
  • Transaction#location
    • Returns the location for that given transaction
  • Transaction#amount
    • Returns the amount spent on that given transaction

Build the following methods on the Location class

A location is initialized with a name as a string. The name of the location can be changed after being initialized.

  • Location#name
    • Returns the name of this location
  • Location.all
    • Returns an array of all Location instances

Associations and Aggregate Methods

Customer

  • Customer#transactions
    • Returns an array of the transactions associated with that customer
  • Customer#locations
    • Returns an array of location instances that a customer has shopped at
  • Customers#total_spent
    • totals and returns the total amount that a user has spent at all locations
  • Customers#average_spent
    • returns the average of all transactions that a customer has

Location

  • Location#transactions
    • Returns an array of the transactions associated with that location
  • Location#customers
    • Returns an array of unique customer instances who have purchased from this location
  • Location#unique_customers
    • Returns an array of all unique customers (ex: if someone has purchased from here more than once, they would still only show once in this array. There is Ruby method that does this for you that you can google for)

budget-tool-oo's People

Contributors

dstoll243 avatar

Watchers

 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.