классы - Не могу запустить класс Ruby


0

Только начал учить Ruby и столкнулся с такой проблемой: Создал два класса , один из них можно считать самой игрой "Собачьи Бега" Но не могу инициализировать этот класс.(Хотя класс собак инициализировать смог).Цикл даже не решаюсь создавать пока хоть раз не запущу игру :/ Собственно вот сам код:

class DOG
def initialize(breed,name,weight=0,height=0,speed=0)
    @the_weight = weight
    @the_height = height
    @the_breed = breed.capitalize
    @the_name = name.capitalize
    @the_speed = speed
end
def to_s
    "                    DOG INFORMATION
              His name is: #{@the_name}
              His breed is: #{@the_breed}
              His weight is: #{@the_weight} cm
              His height is: #{@the_height} kg
          His average speed is: #{@the_speed} km/h
    "
end
end

class GAME
def initialize_game
   luckS = rand(0..10)
   luckR = rand(0..10)
   luckW = rand(0..10)
    if choose_dog == "Steven" or choose_dog == "steven" or choose_dog == "whippetn" or choose_dog == "Whippetn"
        if choose_rate == 3.33
            puts "You choosed , your rate is 3.33!"
            puts "The game starts!"
            if luckS > luckR and luckS > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 6.66
            puts "You choosed , your rate is 6.66!"
            puts "The game is starts!"
            if luckS > luckR and luckS > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 10.00
            puts "You choosed , your rate is 10.00!"
            puts "The game is starts!"
            if luckS > luckR and luckS > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
    end
    if choose_dog == "Richardn" or choose_dog == "richardn" or choose_dog == "greyhoundn" or choose_dog == "Greyhoundn"
        puts "Great pick!"
        puts "Choose rate!"
        puts "First rate is 3.33 , please write in 3.33 if you want to pick that rate"
        puts "Second rate is 3.33 , please write in 6.66 if you want to pick that rate"
        puts "Third rate is 3.33 , please write in 10.00 if you want to pick that rate"
        if choose_rate == 3.33
            puts "You choosed , your rate is 3.33!"
            puts "The game is starts!"
            if luckR > luckS and luckR > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 6.66
            puts "You choosed , your rate is 6.66!"
            puts "The game is starts!"
            if luckR > luckS and luckR > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 10.00
            puts "You choosed , your rate is 10.00!"
            puts "The game is starts!"
            if luckR > luckS and luckR > luckW
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
    end
    if choose_dog == "Whilleyn" or choose_dog == "whilleyn" or choose_dog == "salukin" or choose_dog == "Salukin"
        puts "Great pick!"
        puts "Choose rate!"
        puts "First rate is 3.33 , please write in 3.33 if you want to pick that rate"
        puts "Second rate is 3.33 , please write in 6.66 if you want to pick that rate"
        puts "Third rate is 3.33 , please write in 10.00 if you want to pick that rate"
        if choose_rate == 3.33
            puts "You choosed , your rate is 3.33!"
            puts "The game is starts!"
            if luckW > luckS and luckW > luckR
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 6.66
            puts "You choosed , your rate is 6.66!"
            puts "The game is starts!"
            if luckW > luckS and luckW > luckR
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
        if choose_rate == 10.00
            puts "You choosed , your rate is 10.00!"
            puts "The game is starts!"
            if luckW > luckS and luckW > luckR
                puts "You win!"
                puts "Take your cash."
                money = money + (money*choose_rate)
            else
                puts "You lose"
                money = money - (money*choose_rate)
            end
        end
    end
end
end
puts "Hello to our "Dogs Runs!""
    money = 1000
    puts "Heres information about our dogs"
    dog1=DOG.new("whippet","Steve",15,48,50)
    puts dog1
    dog2=DOG.new("greyhound","Richard",34,73,70)
    puts dog2
    dog3=DOG.new("saluki","Whilley",20,61,60)
    puts dog3
    puts "Please , write in dogs name or breed:"
    choose_dog = gets.to_s
    puts "Great pick!"
    puts "Choose rate!"
    puts "First rate is 3.33 , please write in 3.33 if you want to pick that rate"
    puts "Second rate is 3.33 , please write in 6.66 if you want to pick that rate"
    puts "Third rate is 3.33 , please write in 10.00 if you want to pick that rate"
    choose_rate = gets.to_f
    GAME.new.initialize_game
Источник
  •  2050
  •  0
  • 22 янв 2019 2019-01-22 17:14:14
Что происходит после вызова GAME.new.initialize_game? Чему перед этой строчкой равны choose_dog и choose_rate? Зачем нужны переменные dog1, dog2 и dog3? — 22 янв 20192019-01-22 17:30:11.000000
На англоязычном стэке подсказали что стоит ввести эту строчку, но она никак не помогает. Я инициализировал класс собак: "dog1=DOG.new("whippet","Steve",15,48,50) puts dog1" Но не получается запустить саму игру. — 22 янв 20192019-01-22 17:25:40.000000
"Но не могу инициализировать этот класс." - а что делает GAME.new.initialize_game? — 22 янв 20192019-01-22 17:19:57.000000

Ответов пока нет