Hello. That's right. I started programming on April 27, just two months ago. Currently, I am studying Go exclusively, but on the first day I started programming, I did a Ruby course at Progate, so I entered from Ruby. The reason I chose Ruby first was because it was a famous language that I knew two months ago, so I chose it because I wanted to wrap it in a long one without thinking deeply. I took two laps of the Ruby course over about two days. I still remember clearly that I couldn't understand at all from the second half. Lol After that, the first original application that I made immediately to fix it came out when I was organizing the folders, so I will keep it as a record.
Its name is also "Eevee". That's right, that Eevee. It's an app that lets you choose whether to use water stones or flame stones for Eevee, evolve it, and at the same time learn new techniques. Here is the code.
eevee.rb
class Pokemon
attr_accessor :name, :sex, :skill
def initialize(name:, sex:, skill:)
@name = name
@sex = sex
@skill = skill
end
def who
"Nice to meet you.#{@name}That's right.\n my gender is#{@sex}That's right.\n Special Moves#{skill}That's right."
end
end
eevee = Pokemon.new(
name: 'Eevee',
sex: 'male',
skill: 'wag its tail'
)
puts eevee.who
class Evolution < Pokemon
attr_accessor :new_name
def name_change
@new_name = "hanako"
end
def who_e
"Congrats! Eevee#{name}Has evolved into!\n new#{skill}I remembered!"
end
end
fires = Evolution.new(
name:'Fires',
sex: nil,
skill:'Kaenhosha'
)
showers = Evolution.new(
name:'Vaporeon',
sex:nil,
skill:'Reito Beam'
)
puts "Which stone do you use?\n Please select.\n\n1.Flame stone\n2.Water stone"
answer = gets.chomp.to_i
if answer == 1
puts fires.who_e
elsif answer == 2
puts showers.who_e
end
#=================================@The name entered in name could not be assigned to display.==================
# puts "Do you want to give a nickname?\n Please select.\n\n1.Put on\n2.Do not attach"
# nickname_answer = gets.chomp.to_i
# if nickname_answer == 1 && answer ==1
# puts "Please enter a new name."
# fires.name_change
# puts "name is#{@new_name}It changed to!"
# elsif nickname_answer == 1 && answer ==2
# puts "Please enter a new name."
# showers.name_change
# puts "name is#{@new_name}It changed to!"
# else
# puts "It's the end."
# end
I tried to give it a nickname like an actual Pokemon, but I couldn't give it a comment. Lol At this time, I was confused and felt that I was able to do it for some reason, so I feel that I have grown up compared to two months ago. Since I made a Twitter-like app with Rails in early May, I've been doing Go since I switched to Go, but I also want to touch Ruby before I completely forget it.
I only bought the Kindle version of this Ruby book. I couldn't read much because I changed immediately, but it was just right for me who just finished Progate.
Recommended Posts