Giter Site home page Giter Site logo

real_estate_2008's Introduction

Real Estate

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 three existing tests, and then use TDD to create a Room class that responds to the following interaction pattern:

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

pry(main)> room = Room.new(:bedroom, 10, "13")
#=> #<Room:0x00007fa53b9ca0a8 @category=:bedroom, @length=10, @width="13">

pry(main)> room.category
#=> :bedroom

pry(main)> room.area
#=> 130

pry(main)> room.is_painted?
#=> false

pry(main)> room.paint

pry(main)> room.is_painted?
#=> true

Iteration 2

Use TDD to create a House class that responds to the following interaction pattern: * Where you see something like #<House:0x00007fccd30375f8...>, this is shorthand for a full house object with that object identifier - we have replaced any attributes with ... for readability.

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

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

pry(main)> house = House.new("$400000", "123 sugar lane")
#=> #<House:0x00007fccd30375f8...>

pry(main)> house.price
#=> 400000

pry(main)> house.address
#=> "123 sugar lane"

pry(main)> house.rooms
#=> []

pry(main)> room_1 = Room.new(:bedroom, 10, '13')
#=> #<Room:0x00007fccd29b5720...>

pry(main)> room_2 = Room.new(:bedroom, 11, '15')
#=> #<Room:0x00007fccd2985f48...>

pry(main)> house.add_room(room_1)

pry(main)> house.add_room(room_2)

pry(main)> house.rooms
#=> [#<Room:0x00007fccd29b5720...>, #<Room:0x00007fccd2985f48...>]

Iteration 3

Use TDD to update your House class so that it responds to the following interaction pattern. * A house is above_market_average if its price is greater than $500,000.

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

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

pry(main)> house = House.new("$400000", "123 sugar lane")
#=> #<House:0x00007fccd30375f8...>

pry(main)> house.above_market_average?
#=> false

pry(main)> room_1 = Room.new(:bedroom, 10, '13')
#=> #<Room:0x00007fccd29b5720...>

pry(main)> room_2 = Room.new(:bedroom, 11, '15')
#=> #<Room:0x00007fccd2985f48...>

pry(main)> room_3 = Room.new(:living_room, 25, '15')
#=> #<Room:0x00007fccd383c2d0...>

pry(main)> room_4 = Room.new(:basement, 30, '41')
#=> #<Room:0x00007fccd297dc30...>

pry(main)> house.add_room(room_1)

pry(main)> house.add_room(room_2)

pry(main)> house.add_room(room_3)

pry(main)> house.add_room(room_4)

pry(main)> house.rooms_from_category(:bedroom)
#=> [#<Room:0x00007fccd29b5720...>, #<Room:0x00007fccd2985f48...>]

pry(main)> house.rooms_from_category(:basement)
#=> [#<Room:0x00007fccd297dc30...>]

pry(main)> house.area
#=> 1900

pry(main)> house.details
#=> {"price" => 400000, "address" => "123 sugar lane"}

Iteration 4

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

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

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

pry(main)> house = House.new("$400000", "123 sugar lane")
#=> #<House:0x00007fccd30375f8...>

pry(main)> room_1 = Room.new(:bedroom, 10, '13')
#=> #<Room:0x00007fccd29b5720...>

pry(main)> room_2 = Room.new(:bedroom, 11, '15')
#=> #<Room:0x00007fccd2985f48...>

pry(main)> room_3 = Room.new(:living_room, 25, '15')
#=> #<Room:0x00007fccd383c2d0 @category=:living_room, @length=25, @width=15>

pry(main)> room_4 = Room.new(:basement, 30, '41')
#=> #<Room:0x00007fccd297dc30 @category=:basement, @length=30, @width=41>

pry(main)> house.add_room(room_4)

pry(main)> house.add_room(room_1)

pry(main)> house.add_room(room_3)

pry(main)> house.add_room(room_2)

pry(main)> house.price_per_square_foot
#=> 210.53

pry(main)> house.rooms_sorted_by_area
#=> [#<Room:0x00007fccd297dc30...>, #<Room:0x00007fccd383c2d0...>, #<Room:0x00007fccd2985f48...>, #<Room:0x00007fccd29b5720...>]

pry(main)> house.rooms_by_category
#=> {:bedroom=>[#<Room:0x00007fccd29b5720...>, #<Room:0x00007fccd2985f48...>], :living_room=> [#<Room:0x00007fccd383c2d0...>], :basement=> [#<Room:0x00007fccd297dc30...>]}

real_estate_2008's People

Contributors

cpfergus1 avatar mikedao 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.