Giter Site home page Giter Site logo

car_dealership_2301's Introduction

Car Dealership

Instructions

  • Fork this Repository
  • Clone YOUR fork
  • Compete the activity below
  • Push your solution to your fork
  • Submit a pull request from your repository to the turingschool-examples repository
  • Make sure to put your name in your PR!

Iteration 1

Start with the existing tests, and then use TDD to create a Car class that responds to the following interaction pattern. You are expected to write your own tests for the paint! and color methods.

(Where you see something like #<Car:0x00007fccd30375f8...>, this is shorthand for a full car object with that object identifier - we have replaced any attributes with ... for readability.)

Notes: Loan length is in month, and the total cost is the loan length multiplied by the monthly payment.

pry(main)> require './lib/car'
#=> true

pry(main)> car = Car.new("Ford Mustang", 1500, 36)
#=> #<Car:0x00007fa53b9ca0a8...>

pry(main)> car.make
#=> "Ford"

pry(main)> car.model
#=> "Mustang"

pry(main)> car.monthly_payment
#=> 1500

pry(main)> car.loan_length
#=> 36

pry(main)> car.total_cost
#=> 54000

pry(main)> car.color
#=> nil

pry(main)> car.paint!(:blue)

pry(main)> car.color
#=> :blue

Iteration 2

Use TDD to create a Dealership class that responds to the following interaction pattern:

(Where you see something like #<Dealership:0x00007fccd30375f8...>, this is shorthand for a full dealership object with that object identifier - we have replaced any attributes with ... for readability.)

pry(main)> require './lib/car'
#=> true

pry(main)> require './lib/dealership'
#=> true

pry(main)> dealership = Dealership.new("Acme Auto", "123 Main Street")
#=> #<Dealership:0x00007fccd30375f8...>

pry(main)> dealership.inventory
#=> []

pry(main)> dealership.inventory_count
#=> 0

pry(main)> car_1 = Car.new("Ford Mustang", 1500, 36)
#=> #<Car:0x00007fa53b9ca0a8...>

pry(main)> car_2 = Car.new("Toyota Prius", 1000, 48)
#=> #<Car:0x00007fccd2985f48...>

pry(main)> dealership.add_car(car_1)

pry(main)> dealership.add_car(car_2)

pry(main)> dealership.inventory
#=> [#<Car:0x00007fa53b9ca0a8...>, #<Car:0x00007fccd2985f48...>]

pry(main)> dealership.inventory_count
#=> 2

Iteration 3

Use TDD to update your Dealership class so that it responds to the following interaction pattern:

  • A dealership has inventory if it has at least one car.
pry(main)> require './lib/car'
#=> true

pry(main)> require './lib/dealership
#=> true

pry(main)> dealership = Dealership.new("Acme Auto", "123 Main Street")
#=> #<Dealership:0x00007fccd30375f8...>

pry(main)> dealership.has_inventory?
#=> false

pry(main)> car_1 = Car.new("Ford Mustang", 1500, 36)
#=> #<Car:0x00007fccd29b5720...>

pry(main)> car_2 = Car.new("Toyota Prius", 1000, 48)
#=> #<Car:0x00007fccd2985f48...>

pry(main)> car_3 = Car.new("Toyota Tercel", 500, 48)
#=> #<Car:0x00007fccd383c2d0...>

pry(main)> car_4 = Car.new("Chevrolet Bronco", 1250, 24)
#=> #<Car:0x00007fccd297dc30...>

pry(main)> dealership.add_car(car_1)

pry(main)> dealership.add_car(car_2)

pry(main)> dealership.add_car(car_3)

pry(main)> dealership.add_car(car_4)

pry(main)> dealership.has_inventory?
#=> true

pry(main)> dealership.cars_by_make("Toyota")
#=> [#<car:0x00007fccd2985f48...>, #<car:0x00007fccd383c2d0...>]

pry(main)> dealership.cars_by_make("Ford")
#=> [#<Car:0x00007fccd29b5720...>]

pry(main)> dealership.total_value
#=> 156000

pry(main)> dealership.details
#=> {"total_value" => 156000, "address" => "123 Main Street"}

Iteration 4

Use TDD to update your Dealership class so that it responds to the following interaction pattern:

  • Car price should be from cheapest to most expensive.
pry(main)> require './lib/car'
#=> true

pry(main)> require './lib/dealership
#=> true

pry(main)> dealership = Dealership.new("Acme Auto", "123 Main Street")
#=> #<Dealership:0x00007fccd30375f8...>

pry(main)> car_1 = Car.new("Ford Mustang", 1500, 36)
#=> #<Car:0x00007fccd29b5720...>

pry(main)> car_2 = Car.new("Toyota Prius", 1000, 48)
#=> #<Car:0x00007fccd2985f48...>

pry(main)> car_3 = Car.new("Toyota Tercel", 500, 48)
#=> #<Car:0x00007fccd383c2d0...>

pry(main)> car_4 = Car.new("Chevrolet Bronco", 1250, 24)
#=> #<Car:0x00007fccd297dc30...>

pry(main)> dealership.add_car(car_1)

pry(main)> dealership.add_car(car_2)

pry(main)> dealership.add_car(car_3)

pry(main)> dealership.add_car(car_4)

pry(main)> dealership.average_price_of_car
#=> "39,000"

pry(main)> dealership.cars_sorted_by_price
#=> [#<Car:0x00007fccd383c2d0...>, #<Car:0x00007fccd297dc30...>, #<Car:0x00007fccd2985f48...>, #<Car:0x00007fccd29b5720...>]

pry(main)> dealership.inventory_hash
#=> {"Ford"=> [#<Car:0x00007fccd29b5720...>],
"Toyota"=> [#<Car:0x00007fccd2985f48...>, #<Car:0x00007fccd383c2d0...>],
"Chevrolet"=> [#<Car:0x00007fccd297dc30...>]}

car_dealership_2301's People

Contributors

brianisthebest avatar epintozzi 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.