Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project complete #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
19 changes: 7 additions & 12 deletions animal.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# Define Animal as a class
class Animal

# Set up accessors and mutators for the attributes of an Animal
# attr_accessor sets up both for you
attr_accessor :name, :age, :gender, :species, :toys

# Used when creating a new animal.
# Example:
# Animal.new('Timmy', 4, 'male', 'toad')
def initialize(name, age, gender, species)

@name = name
@age = age
@gender = gender
@species = species
@toys = []
end

# When we display the animal using puts or print, the
# to_s method is called to pretty print an Animal
def to_s

"#{@name} is a #{@age} year old #{@gender} #{@species} that loves #{@toys.join(", ")}"
end
end
end
23 changes: 23 additions & 0 deletions client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Client
attr_accessor :name, :age, :gender, :num_children, :pets

def initialize(name, age, gender, num_children)
@name = name
@gender = gender
@num_children = num_children
@age = age
@pets = {}
end

def to_s
"#{@name} is a #{@age} year old #{@gender} with #{@num_children} kids and #{@pets.length} pets"
end

def display_pets
pet_info = []
@pets.each { |key,val| pet_info.push(val.to_s) }
pet_info.join("\n")

end

end
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"covered_percent": 100.0
"covered_percent": 71.43
}
}
77 changes: 70 additions & 7 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,61 @@
{
"RSpec": {
"coverage": {
"/Users/jacquelineherrlin/GeneralAssembly/WDI_2014/animal_shelter/starter_code/animal.rb": [
"/Users/TPCMacbookAir/Developer/projects/HappiTailsMiniProject/animal.rb": [
1,
1,
null,
1,
0,
0,
0,
0,
0,
null,
null,
1,
0,
null,
null
],
"/Users/TPCMacbookAir/Developer/projects/HappiTailsMiniProject/shelter.rb": [
1,
1,
null,
1,
5,
5,
5,
5,
null,
null,
1,
1,
null,
null,
1,
0,
0,
0,
null,
null,
1,
1,
2,
1,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
Expand All @@ -21,15 +64,35 @@
1,
null,
null,
null,
null
],
"/Users/jacquelineherrlin/GeneralAssembly/WDI_2014/animal_shelter/starter_code/shelter.rb": [

],
"/Users/jacquelineherrlin/GeneralAssembly/WDI_2014/animal_shelter/starter_code/person.rb": [

"/Users/TPCMacbookAir/Developer/projects/HappiTailsMiniProject/client.rb": [
1,
1,
null,
1,
1,
1,
1,
1,
1,
null,
null,
1,
1,
null,
null,
1,
0,
0,
0,
null,
null,
null,
null
]
},
"timestamp": 1397016177
"timestamp": 1397255892
}
}
10 changes: 5 additions & 5 deletions data.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# require the local files where the classes are defined
require_relative 'shelter'
require_relative 'person'
require_relative 'client'
require_relative 'animal'

# Instantiate a Shelter
$shelter = Shelter.new('HappiTails', '10 east 21st Street')

# Instantiate clients. Insert them into the shelter's clients hash
$shelter.clients['Bob'] = Person.new('Bob', 22, 'male', 0)
$shelter.clients['Sue'] = Person.new('Sue', 31, 'female', 2)
$shelter.clients['Jil'] = Person.new('Jil', 46, 'female', 1)
$shelter.clients['Sam'] = Person.new('Sam', 87, 'male', 3)
$shelter.clients['Bob'] = Client.new('Bob', 22, 'male', 0)
$shelter.clients['Sue'] = Client.new('Sue', 31, 'female', 2)
$shelter.clients['Jil'] = Client.new('Jil', 46, 'female', 1)
$shelter.clients['Sam'] = Client.new('Sam', 87, 'male', 3)

# Instantiate animals. Insert them into the shelter's animals hash
$shelter.animals['Spot'] = Animal.new('Spot', 3, 'male', 'Dog')
Expand Down
1 change: 0 additions & 1 deletion main.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'pry'
require 'rainbow'
require_relative 'data'
require_relative 'functions'

response = #set this equal to something
while response != 'Q'
Expand Down
47 changes: 47 additions & 0 deletions shelter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class Shelter
attr_accessor :shelter_name, :address, :clients, :animals

def initialize(shelter_name,address)
@shelter_name = shelter_name
@address = address
@animals = {}
@clients = {}
end

def to_s
"#{@shelter_name} shelter at #{@address} has #{@animals.length} animals and #{@clients.length} people"
end

def display_animals
animal_info = []
@animals.each { |key,val| animal_info.push(val.to_s) }
animal_info.join("\n")
end

def display_clients
client_info = []
@clients.each { |key,val| client_info.push(val.to_s) }
client_info.join("\n")
end

# takes an Animal object from a Client and adds it to the shelter

# aka take an Animal from the client's pets{} and put it in shelters animals {}

# aka...
# access @pets hash in Client class
# key:value pair will be :petname => [pet instance of Animal class] ---right???
# pop that object out of @clients.pets
# push that Animal object onto the @animals hash in the Shelter class

# surrendered = Animal.new("Unlucky", 2, "female", "cat" ) #pretend surrendered = instance of Animal class = a cat named Unlucky
# @client.pets[surrendered.name.to_sym].pop # we find the :surrendered key and pop it off the @pets hash in Clients (can you do that?)
# @animals = {:Unlucky => surrendered} # push it onto the @animals hash with the key = :Unlucky, value = object in Animal class called surrendered

# @client.pets[tiny.name.to_sym] = tiny

def adopt

end

end
2 changes: 1 addition & 1 deletion spec/shelter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

describe ".display_clients" do
it "prints the Shelter object's Clients" do
client = Person.new("Beth", 30, "female", 3)
client = Client.new("Beth", 30, "female", 3)
@shelter.clients[client.name.to_sym] = client
expect(@shelter.display_clients).to match("Beth is a 30 year old female with 3 kids and 0 pets")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# For our specs to run, we need to require the Ruby classes we’re testing
require_relative '../animal'
require_relative '../shelter'
require_relative '../person'
require_relative '../client'

# Configure RSpec
RSpec.configure do |config|
Expand Down