Last active
December 30, 2015 18:09
-
-
Save ZacharyDinerstein/7866006 to your computer and use it in GitHub Desktop.
happyTails_app.rb Currently debugging...
This file contains 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
def menu | |
@happiTails = Shelter.new | |
puts "Do you want to: " | |
puts "Show all animals (sa)" | |
puts "Show all clients (sc)" | |
puts "Create an animal (ca)" | |
puts "Create a client (cc)" | |
puts "Help a client adopt an animal (a)" | |
puts "Help a client put an animal up for adoption (p)? " | |
print "Or quit (q)? " | |
choice = gets.chomp | |
case choice | |
when "sa" | |
if @happiTails.shelter_animals == [] | |
puts "\nThere are no aminals in the shelter." | |
else | |
@happiTails.show_animals | |
end | |
when "sc" | |
if @happiTails.shelter_clients == [] | |
puts "\nWe have no clients right now. We really oughta change our business model..." | |
else | |
@happiTails.show_clients | |
end | |
when "ca" | |
@happiTails.add_animal | |
when "cc" | |
@happiTails.add_client | |
when "a" #BOOKMARK -- STOPPED BUILDING HERE... | |
when "p" | |
when "q" | |
@done = true | |
else | |
puts "\nSorry future adoptor! That's not a valid option." | |
end | |
end | |
class Animal | |
attr_accessor :name, :age, :gender, :species, :toys, :type | |
def initialize(options = {}) | |
@name = options[:name] || "unknown" | |
@age = options[:age] || "unknown" | |
@gender = options[:gender] || "unknown" | |
@species = options[:species] || "unknown" | |
@type = options[:type] || "unknown" | |
@toys = options[:toys] || [] | |
end | |
end | |
class Client | |
attr_accessor :name, :age, :gender, :children, :pets | |
def initialize(options = {}) | |
@name = options[:name] || "unknown" | |
@children = options[:children] || "unknown" | |
@age = options[:age] || "unknown" | |
@pets = options[:pets] || "unknown" | |
end | |
def adopt | |
end | |
end | |
class Shelter | |
attr_reader :name, :shelter_animals, :shelter_clients | |
def initialize(options = {}) | |
@name = options[:name] || "happiTails" | |
@shelter_animals = options[:shelter_animals] || [] | |
@shelter_clients = options[:shelter_clients] || [] | |
end | |
def show_clients | |
return @shelter_clients | |
end | |
def show_animals | |
return @shelter_animals | |
end | |
def add_client | |
newClient = Client.new | |
print "\nWhat's the new client's name? " | |
newClient.name = gets.chomp | |
print "\nHow old are they? " | |
newClient.age = gets.chomp | |
print "\nHow many children do they have? " | |
newClient.children = gets.chomp | |
print "\nHow many pets do they have now? " | |
newClient.pets = gets.chomp | |
@shelter_clients << newClient | |
end | |
def add_animal | |
newAnimal = Animal.new | |
print "\nWhat's the new animal's name? " | |
newAnimal.name = gets.chomp | |
print "\nWhat kind of animal? " | |
newAnimal.species = gets.chomp | |
print "\nWhat kind of #{newAnimal.species}? " | |
newAnimal.type = gets.chomp | |
print "\nHow old are they? " | |
newAnimal.age = gets.chomp | |
print "\nGender? " | |
newAnimal.gender = gets.chomp | |
print "\nHow many toys do they have? " | |
newAnimal.toys = gets.chomp | |
@shelter_animals << newAnimal #BUG -- Program breaks here. undefined method `shelter_animals' for nil:NilClass (NoMethodError) | |
end | |
end | |
class Relationships | |
end | |
require_relative '../happiTails_app' | |
This file contains 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 'pry' | |
require_relative 'classes/classes' | |
puts | |
#Creates out happyTrails shelter off the bat. | |
@done = false #Quits program if user chooses "q" from the menu | |
while @done == false #...otherwise, the menu repeats. | |
menu | |
puts | |
puts | |
end | |
binding pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment