Free Essay

Ruby Program

In:

Submitted By zidane88
Words 307
Pages 2
# Exercise 35 Branches and Functions

def gold_room puts "This room is full of gold. How Much do you take?" print "> " choice = $stdin.gets.chomp # this line has a bug, so fix it if choice =~ /[0-9]/ how_much = choice.to_i() else dead("Man, learn to type a number.") end if how_much < 50 puts "Nice, you are not greedy, you win" exit(0) else dead("You greedy bastard!") end end def bear_room puts "There is a bear here" puts "The bear has a bunch of honey" puts "The fat bear is in front of another door." puts "How are you going to move the bear?" bear_moved = false while true print "> " choice = $stdin.gets.chomp if choice == "take honey" dead("The bear looks at you then slaps your face off!") elsif choice == "taunt bear" && !bear_moved puts "The bear has moved from the door. You can go through now!" bear_moved = true elsif choice == "taunt bear" && bear_moved dead("The bear gets pissed and chews your leg off!") elsif choice == "open door" && bear_moved gold_room else puts "I got no idea what that means!" end end end def cthulhu_room puts "Here you see the great evil Cthulhu." puts "He, it, whatever stares at you and you go insane." puts "Do you flee for your life or eat your head?" print "> " choice = $stdin.gets.chomp if choice.include? "flee" start elsif choice.include? "head" dead("Well that was tasty!") else cthulhu_room end end def dead(why) puts why, "Good Job!" exit(0) end def start puts "You are in dark room." puts "Thgere is a door to your right and left" puts "Which one do you take?" print "> " choice= $stdin.gets.chomp if choice == "left" bear_room elsif choice == "right" cthulhu_room else dead("You stumble around the room until you starve.") end end start

Similar Documents

Free Essay

Astral

...The countryside was lush, sparkling with a plum blue serene from the early morning sunrise. Atop the highest of the Vilorian Mountains, the city of Astral stood silent against the ringing of silver trumpets from the north highlands. The travelers crossing the last of the mountains rocky crossings took in the scene from under the fruits of a Bombaly tree, standing colossal at one hundred meters in height. Petty fruits the size of a child’s fist lay strewn about under its goliath canopy, dripping with ruby red nectar. The morning wind was crisp and slightly harsh, a sign to all that the winter seasons were coming with quickness. The trail leading up to the city was a four day expedition from the coast, and it had been a taxing journey for all in company. From where he lingered on the edge of the vast mountain Cyril looked down upon the Port of Themme, twenty leagues off. The brilliant light of the day lit up the ocean and surrounded all with a dazzling view of the great maritime reefs that stretched as far as the eye could see. The vastness of the blue ocean always seemed to enlighten Cyril when it stared up at him from the deep, and like always, he treasured the view for a fleeting moment. But with great beauty comes great sorrow, and at that moment the reality of the daunting mission he was on got the better of him, turning his gaze southwards to his...

Words: 251 - Pages: 2

Premium Essay

Sam Winchester Monologue

...It's early in the morning, a Tuesday ironically, when Billy gets the call to collect Sam Winchester’s soul. She's surprised that Sam is being collected, and Dean isn't, because she had always assumed they would go out swinging, together. When she gets to Sam, the scene before her is nothing like she imagined the younger Winchester’s death to look like. There are no demons, or angry spirits, he isn't killed by a wendigo, or a witch. He's killed by a seventeen year old boy, driving an old Chevy pickup. Sam is lying almost motionless, in the middle of a quiet road. He’s the victim of a hit and run. There’s an awful lot of blood surrounding him, pooling around his chest, and his blood is bubbling rhythmically from his mouth. As a reaper, she's seen her fair share of hit and run deaths, but this is different. This is Sam Winchester, the man who saved the world from Apocalypse, not once but twice, the man who rid the world of the devil, twice. The man who has killed thousands of evil creatures alongside his brother, and now here he lay, in the middle of the road, after being hit by a truck. Alone. She can see the pain he’s in, see the tears rushing from his eyes, she can hear him calling out to his older brother, but no one will hear him. She can see the events leading up to his death, Sam leaving his and Dean's hotel room, to go on a walk after an insignificant argument, following the side of the road for exactly three miles, before a truck comes hurdling down the wrong side of...

Words: 1262 - Pages: 6

Premium Essay

Access Ols

...List the steps you would take to access OLS. • Go to https://ecampus.phoenix.edu and enter you user name and password How do you access the Main forum? •Once you are on the class you want to be in at the top there are 4 tabs labeled Materials, Discussion, Assignments and Grades, click on Discussion and it will place you at the Main forum. How do you access your Individual forum? •Per above, once you have accessed the forums there is a box labeled Forums on the left side of your screen, click on you name under the Individual Forum header. How did you find the Orientation Workshop readings? •Once logged into OLS your classes are listed under Current Classes and you can click the class or the Materials like which will bring up the Materials tab for all your read material. Where must you post your assignments? •Once under you class you click on the Assignments tab, once there click on the assignment you want to turn in. Load you word document under the Submit Assignment area to turn in. Where do class discussions for participation take place? •In the Main forum. What do you need to do to read replies to messages in the Main forum? •Click on the Thread you wish to open and click on the RE: you want to read. What steps would you take to reply to a message in the Main forum? •Click on the Thread I wished to read and reply to. Once read I would click Reply on the right side of the header. How can you recognize a message posted by your facilitator? •By the graduate cap...

Words: 326 - Pages: 2

Free Essay

Group Assignment

...Group Assignment#1 Date Due: March 24/15(Week 12) * worth 20% of your final grade Pick a chapter from your text, research it then present it with your group to the rest of the class. The chapter chosen should be one that will not be presented by the instructor (suggest one of the online class chapters). Each of the groups must pick a different chapter. The presentation should be at least 30 minutes, and professional. Each student will be responsible for the following three components: Presentation - 30% Your task is to research the topic and present it in class. Presentations will run no more than 30 minutes in length. You may present, and complete your topic however you choose. It is recommended that you include some type of participation from the class in your presentation.  Your grade will be based on the following: *Visual Component: Visual aid(s) used to enhance the presentation *Participation: Have the class participate as a component of the presentation * due to time factor, only discuss what class activity would involve) *Creativity: The presentation is to be delivered using a creative approach. *Knowledge of Topic: A demonstrated knowledge about the chapter presented; all the information was clear and contained sufficient detail. Clarification was given when questions were asked. *Organization: The information was presented in an organized and logical fashion for easy understanding. *Time Frame: The presentation was delivered within the required...

Words: 484 - Pages: 2

Free Essay

Intro to Communication Chapter 5 Reflection Paper

...CMST 192 2:00-3:15 pm - Dr. Fischer Chapter 5 Reflection Listening skills are a very important for each and every person to have. Without them, how is one able to understand another? We are all guilty of poor listening at some point, especially in this generation because of all the technology we have access to. Cell phones are one of the biggest distractions to listening that I have seen. A lot of times you will see students sitting on their phones during the middle of a lecture or even sitting on their phones at a dinner table rather than listening to what the people around them have to say. Other examples of reasons for poor listening are things like the effort a person is willing to put in, being overloaded with too much information at once, not knowing enough about the topic prior, just listening to respond and not actually taking what the person is saying into consideration or simply just not having respect for a person who may be speaking. There are many ways that a person can help themselves become a better listener such as reducing noise, putting in the effort to listen, stay focused on the conversation, try to have prior knowledge, avoid distractions and be respectful! I personally am someone who is very easily distracted by my phone during classes and that is something I am trying to work on because as soon as I put it away I will get so much more out of the classes I am taking. Noise doesn’t just have to be physical, it can be psychological which is what distracts...

Words: 387 - Pages: 2

Free Essay

Buisness

...Taking online classes and reaching one's maximum potential can be quite a challenge. In order to complete classes one must be able to set realistic goals and time-lines. A plan must be designed to incorporate work, family, and school. Last but not least, one must face the challenge of not physically being present in a classroom setting. Online classes can be a unique challenge, however; it is not impossible to successfully complete courses. Realistic goals and time-lines are almost always the key to being successful in anything one may do, online classes are no exception. Setting goals at the beginning of each course as to the grade one would like to achieve. Another goal that could be set is what does one want to learn and get out of the particular course. Tasks must be set in place for each day that the individual knows that they can accomplish. For instance, on day one of an assignment, complete all the necessary reading. Day two listen to any video lectures and read over instructor notes. Day three do homework and any class assignments. Day four review any notes that you have taken and the feedback form instructor as you are preparing for the test that week. Setting goals and time-lines help to keep you on track and where you need to be with the lesson. A plan must be designed to integrate school, work, and family to maintain an equal balance. Working and taking classes of any kind proves to be a challenge. Most people work at least 40 hour work weeks, but some people...

Words: 580 - Pages: 3

Premium Essay

Character Analysis of Dean Winchester

...Anna Prioletti Professor Watts English 102 A24 January 20, 2013 Through the Eyes of Dean Winchester: On the Road and On the Hunt In my favorite TV show, Supernatural, one of the protagonists and my favorite character is Dean Winchester, a certainly very round character. The series begins in Lawrence, Kansas with the demonic death of Dean’s mother Mary. Consequently he, his brother Sam, and his father John are thrust into the world of the supernatural. John becomes obsessed with hunting the evil he encounters and ultimately tracking down the demon that killed Mary. As Dean grows, he learns more and more about hunting, weaponry, and the supernatural creatures that haunt this world. Due to circumstance, he is forced to grow up at an early age as he helps his father and fills the maternal role for Sam. Dean is such a standout and memorable character to me because of his never-failing selflessness, fierce protective nature, and emotionally complex mind. Throughout the show, it is easy to see how selfless Dean is. In his mind, family always comes first no matter the consequences or what may happen to him. Growing up moving from place to place with his hunter father and young brother, Dean learns family is all he has. He and his father had a militaristic relationship in that Dean did whatever he was told and never questioned anything or argued. He put aside any dreams or aspirations he may have had to stick with his dad and help him get revenge while also taking...

Words: 914 - Pages: 4

Premium Essay

Hello

...was packed with people. The sky was clear blue. Occasionaly, we could hear the airplanes soaring above our heads. The Airplanes made white lines around the sky, filling the sky with beautiful patterns made by the white lines. As we started walking to our right, the hustle and bustle of a Bicycle Rental Shop could be heard. Smells of the aroma of mouth watering food could be smelt from a distance. When we entered the shop we were greeted by sales assistants standing by the door. One of the sales assisstants took us to the mountain bike section. As I entered the section, I was amazed by the sight. From head to toe were colourful bikes lining agaiinst the walls. Small bikes, medium bikes and large bikes were piled against the wall. I chosed a ruby red bike and my Uncle chose a blue bike. As we had a day rental, we decided to cycle to Changi Beach and East Point. I hopped on my bike and started to cycle. along the way we passed many shops selling food, drinks, children playing in the sea or building sandcastles. The bicycle trail winded further East. There was a part where the bicycle trail winded near a pach of the beach and we could see the clear blue water rising on the beach and lowering back down into the sea. as it rised, we could see a tiny bit of the beautiful, peaceful, loving underwater world. The water smelt fresh but it also smelt a bit salty. Moving...

Words: 724 - Pages: 3

Free Essay

Happy Prince

...Oscar Wilde It’s a story about a statue that was gilded all over with thin leaves of fine gold, it’s eyes are made of two bright sapphires, and a large red ruby glows on his sword-hilt. Everybody likes the happy prince because they are glad that there is someone who is always happy. One time a little Swallow who was on the way to Egypt ,wants a place to sleep comes to the statue. When he wantsto sleep under the statue , he notices that the Happy Prince is crying. When the Swallow asks why he is crying he answers that he is sad because there are so many unhappy people in the country he wanted to help. So the little Swallow stays the night with the happy prince and takes the red ruby from the Prince’s sword shield to the pour people. The next day the Swallow wants to fly to Egypt but the prince asks him to stay and take the sapphires from his eye to the pour. That happens also the next day, but now the Happy Prince is blind and the Swallow wants to stay with him. Finally the winter comes and the little Swallow dies, but he comes in heaven together with the Happy Prince. The Text Oscar Wilde My Opinion: I think the story is worth reading because it’s easy to understand. I really liked the story because the Prince and the Swallow didn’t think of themselves and helped the poor. They show how we should behave when someone is in misery. Please write your opinion here: Elisabeth: I think that the story is very nice to read and easy to understand. I...

Words: 365 - Pages: 2

Free Essay

Kfc and Its Historic Start

...kfc The beginning of kfc after leaving the family home at the age of 12, Sanders passed through several professions, with mixed success. In 1930, he took over a Shell filling station on U.S. Route 25 just outside North Corbin, a small city on the edge of the Appalachian Mountains. It was here that he first served to travellers the recipes that he had learned as a boy: fried chicken and other dishes such as steaks, country ham, and pancakes. Originally using his own dining room table, in 1934, he purchased the larger filling station across the street and expanded to six tables. By 1936, this had proved successful enough for Sanders to be given the honorary title of Kentucky colonel by Governor Ruby Laffoon. The following year he expanded his restaurant to 142 seats, and added a motel he purchased across the street, naming it Sanders Court & Café. Sanders was dissatisfied with the 30-minute duration it took to prepare his chicken in an iron frying pan, but he refused to sacrifice quality by deep frying the product. In 1939, the first commercial pressure cookers were released onto the market, predominantly designed for steaming vegetables. Sanders bought one, and modified it into a pressure fryer, which he then used to fry chicken. As well as production-time-reducing to be comparable with deep frying, the new method produced flakier, moister chicken. In 1940, he finalised what came to be known as his Original Recipe of 11 herbs and spicesn 1960 the company had some 200 franchised...

Words: 303 - Pages: 2

Premium Essay

Jfk Assassination

...|The Assassination of a President | | The Assassination of President Kennedy | | | | | | | | | In 1963 a lot of events happened, like the earthquake that destroyed a village in Libya, Iron man deputes in the Marvel Comic Books, and the assassination of President John F Kennedy. The Assassination of President Kennedy happened on Friday, November 22 at 12:30 p.m. during a motorcade. The Motorcade was carrying the president to a Luncheon speech at the Trade Mart that was when the shot was fired. One shot was fired and that bullet did a lot of damage, it hit the president and the Governor of Texas. The bullet entered into President Kennedy’s head, and the same bullet hit the governors lower back, damaged the vertebrae, and the right lung. After the shooting they fled the president...

Words: 1121 - Pages: 5

Premium Essay

How Did Jfk Kill Kennedy

...Mysteries and America History JFK JFK’s assassination was very sad, it was a tragic day, but the mystery of how he died is going to be revealed. He died 11/22/63, Friday, at 12:30. Lee Harvey Oswald was part of a larger conspiracy that killed kennedy. There are three reasons, one is that oswald shot him with the help of a conspiracy. Oswald was eating his lunch on the second floor, but the gunshot came from the seventh floor. We believe that he was part of the CIA, which means he shot JFK and was trained to run fast. This could explain why he was eating his lunch on the second floor after he shot kennedy. Lee Harvey Oswald was working with the CIA and a larger conspiracy to conclude the change of route. Kennedy’s first route was going to start...

Words: 421 - Pages: 2

Premium Essay

Lincoln Assassination Research Paper

...Assassination is the killing of a prominent person, either for political or religious reasons or sometimes for payment. Throughout the history of the United States, eight Presidents have died while in office. Four of them died of natural causes, but four others died from assassination. The first assassination of a U.S. President was in 1865, and the last assassination that has occurred was in 1963. Stricter policies have been enforced to ensure the safety for people in office. The very last President to get assassinated was John F. Kennedy, but the very first President to get assassinated was Abraham Lincoln. Overall, the assassination of Abraham Lincoln impacted the world in a negative way and made the United States look weak. Abraham Lincoln was born on the 12th of February in 1809. He was born in a log cabin on “Sinking Spring Farm” three miles south of Hodgenville, Kentucky. He was the son of farmers Thomas Lincoln and Nancy Hanks. Abraham later became the sixteenth President of the United States in March of 1861. He was the first Republican President of the United states. He was well liked by most people while he was in office, “Generally regarded as the greatest and most influential American President, he has attracted the attention of political philosophers, novelists, poets, and champions of various causes, as well as that of professional historians,” and he is obviously still though of highly today. He was reelected in 1864, but did not get to complete this term. To...

Words: 1335 - Pages: 6

Premium Essay

Argumentative Essay On John F Kennedy's Assassination

...hospital. The whole nation is at a stand-still. Thirty minutes later, you hear the heart shattering news. “Our president, John F. Kennedy didn’t survive from the shot. He was pronounced dead at 1pm at the Parkland Memorial Hospital in Dallas, Texas.” What was once going to be a good day turned out to be anything but. His “killer”, Lee Harvey Oswald was originally arrested for the murder of police officer J. D. Tippit. Tippit was murdered in the streets of Dallas 45 minutes after Kennedy was shot. Even though many people believed it to be a inside job, Oswald was still arrested for the murder. Oswald was killed on television while he was getting transferred to their county jail on November 24th. His killer was a owner of nightclubs, Jack Ruby. Jack was known for organizing crime, many people believe that Jack killed Oswald to cover up the truth. Or maybe...to cover up the lies? They’re wasn’t many witnesses of how many shots were taken, or where they came from because everyone was focused on the president. But there still are some witnesses. Many wonder why the police wouldn’t want witnesses to speak about what they heard or saw. One man was even held at gunpoint so he wouldn’t talk about what he saw. There’s many books and movies on this topic such as ‘The Dead Witness’, also, many of the witnesses died of ‘mystery causes’ before they could state their testimony. Coincidence? I think not.. Was it friendly fire? Was it a true assassination by Oswald? I’m not sure. But what I...

Words: 524 - Pages: 3

Free Essay

Grails over J2Ee or Ruby on Rails or Jruby

...Grails over J2EE or Ruby on Rails or jRuby Being one of the lighthouse adopters of Grails/Groovy platform, SigmaInfo also offers jQuery development solutions. The company has been developing interdependent web applications using both Grails/Groovy and jQuery as application development platforms for quite a few years now. Grails application development professionals make intelligent use of the lightweight JavaScript library, jQuery, to enhance web applications. Why use jQuery during Grails application development? jQuery is a JavaScript library commonly used by developers around the world. Like Dojo or YUI, this is also considered a standard web 2.0 plug-in and is quite useful in form validation. Grails web application development professionals @Sigma have chosen jQuery for its myriad advantageous features that are immensely helpful in developing Grails applications. jQuery also helps in Ajax development which is seemingly a complex process. Sigma Grails development team uses jQuery extensively and almost in every application development project. Besides, they also make use of jRuby, jMesa and jqGrid for paginated and classifiable list and grid views. jQuery is used in inline form validation and in making dynamic web 2.0 pop-ups for Grails mobile development. jQuery in Grails applications A number of standard web 2.0 features can be created using jQuery and other sorts of lightweight JavaScript libraries and plug-ins. Some of the standard features that can be found in SigmaInfo...

Words: 283 - Pages: 2