Created
April 18, 2015 18:27
-
-
Save bootcoder/71f6bac9c481d6513825 to your computer and use it in GitHub Desktop.
rent_this_room
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pp' | |
| require 'awesome_print' | |
| require 'colorize' | |
| class House | |
| attr_reader :name, :description, :pictures, :rooms, :address | |
| def initialize(args = {}) | |
| @name = args[:name] | |
| @description = args[:desc] | |
| @pictures = args[:pics] | |
| @rooms = [] | |
| @address | |
| end | |
| def add_room(room) | |
| @rooms << room | |
| end | |
| end | |
| class Room | |
| attr_reader :private_room, :private_bath, :rent, :description, :pictures | |
| def initialize(args = {}) | |
| @tennant_count = 1 | |
| @private_room = true | |
| @private_bath = false | |
| @rent = args[:rent] | |
| @description = args[:desc] | |
| @pictures = args[:pics] | |
| end | |
| end | |
| house = House.new({ | |
| name: "Das Haus des Jägers", | |
| address: "255 Molimo Drive San Francisco CA", | |
| pics: ["https://www.dropbox.com/sh/vtj93b9dttzt02g/AAA1HKRS5tZYoKos1w_zdNzna?dl=0"], | |
| desc: "The hosue is nearly at the top of Mt Davidson. Great Neighborhood and great views. Muni stop is about 100 yards up the hill."}) | |
| house.add_room(Room.new({ | |
| rent: 1400, | |
| pics: ["https://www.dropbox.com/s/57ddr71h50ymupt/2015-04-18%2010.32.50.jpg?dl=0", "https://www.dropbox.com/s/65vibec64da5kw9/2015-04-18%2010.33.22.jpg?dl=0"], | |
| desc: "The larger of the two rooms."})) | |
| house.add_room(Room.new({ | |
| rent: 1200, | |
| pics: ["https://www.dropbox.com/s/fnn84kkgbiwb2lx/2015-04-18%2010.37.47.jpg?dl=0", "https://www.dropbox.com/s/7p1go79epmtpzdm/2015-04-18%2010.37.38.jpg?dl=0"], | |
| desc: "The smaller of the two rooms."})) | |
| puts "-" * 100 | |
| puts (house.name).colorize(:red) | |
| puts (house.description).colorize(:light_blue) | |
| puts house.pictures | |
| puts "-" * 100 | |
| pp house.rooms[0] | |
| puts "-" * 100 | |
| pp house.rooms[1] | |
| puts "-" * 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment