Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
learnrubythehardway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Hoang Mai Phuong
learnrubythehardway
Commits
aeaaff0c
Commit
aeaaff0c
authored
May 20, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20/05
parent
ad052c9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
4 deletions
+136
-4
branch_funtion.rb
+3
-4
game.rb
+133
-0
No files found.
branch_funtion.rb
View file @
aeaaff0c
def
gold_room
def
gold_room
puts
"This room is full of gold. How much do you take?"
print
"> "
...
...
@@ -87,5 +87,5 @@ def gold_room
dead
(
"You stumble around the room until you starve."
)
end
end
gold_room
()
\ No newline at end of file
start
game.rb
0 → 100644
View file @
aeaaff0c
def
dinasour_land
puts
%Q{
\t
This land has a Dinasour challenge.
\t
The Dinasour is slepping in front of the door.
\t
How are you going to pass the room?
\t
You can choose a meat or a gun???.
}
dinasour_moved
=
false
while
true
print
">>"
choice
=
$stdin
.
gets
.
chomp
if
(
choice
==
"meat"
)
dead
"You're so funny but Dinasour will eat you first!!!"
elsif
choice
==
"gun"
&&
!
dinasour_moved
puts
"Oh Dinasour was kill."
quiz_land
dinasour_moved
=
true
elsif
choice
==
"gun"
&&
dinasour_moved
dead
(
"The dinasour gets angry and start chewing your head"
)
else
puts
"I got no idea what that means."
end
end
end
def
quiz_land
puts
%Q{
\t
Welcome to quiz land.
\t
You have 2 questions.
\t
If you answer right both of them.
\t
You will keep going.
}
while
true
puts
%q{
You need to send a value back to the code that called it (return a value to the caller).
Which method can/should be used for this?
A. return
B. replay
C. post
D. send
}
print
">>"
choice
=
$stdin
.
gets
.
chomp
if
choice
==
"A"
puts
" Excelent! Next question"
else
dead
"You can try again!"
end
puts
%q{
Excellent!!!.
You need to convert the string salt to a number in order to see if it exceeds a cutoff value.
Which of the following methods should be used to accomplish this?
A. interger
B. num
C. declare.i
D. to_i
}
choice
=
$stdin
.
gets
.
chomp
if
choice
==
"D"
puts
"Congratulation!!! open the door to go next room"
luxury_room
else
dead
"You can try again:))"
end
end
end
def
luxury_room
puts
%Q{
\t
Hello traveller.
\t
Welcome to last room. This is treasure_room.
\t
The room has many gold, ruby and a key in them.
\t
What is your choose? find a key or quit.
}
print
">>"
choice
=
$stdin
.
gets
.
chomp
if
choice
.
include?
"find"
dead
"you Win!!!"
elsif
choice
.
include?
"quit"
dead
"Hope see you soon"
else
puts
"Please, choose"
end
end
def
dead
(
why
)
puts
why
,
"Bye!"
exit
(
0
)
end
def
start
puts
%Q{
------------------------------------------------
Hello traveller! Welcome you to Teyat land.
Now you choose land
which you want to challenge
dinasour land or quiz land?
------------------------------------------------
}
print
">>"
choice
=
$stdin
.
gets
.
chomp
if
choice
.
include?
"dinasour"
dinasour_land
elsif
choice
.
include?
"quiz"
quiz_land
else
puts
"please choose the land, traveller"
end
end
start
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment