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

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

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

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

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

Summary Of The Kennedy Assassination 24 Hours After

...The Kennedy Assassination- 24 Hours After: Lyndon B. Jonson’s Pivotal First Day as President. By Steven M. Gillon. (New York, N.Y.: Basic Books, 2009.) In 1963, a tragic event created confusion and vulnerability throughout the United States of America. John F. Kennedy, the 35th president of the United States, was assassinated while traveling during a political trip in Dallas, Texas. The book, The Kennedy Assassination- 24 Hours After, written by historian Steven M. Gillon, successfully outlines this view. Gillon recounts the assassination of President John F. Kennedy and reveals compelling evidence regarding the events that took place during Lyndon B. Johnson’s first day in office that would shape his presidency. Throughout the book, Gillon provides insight towards Johnson’s demeanor concerning the chaos and disputes that surrounded the rapid transition of presidential power. While riding in a motorcade through Dallas, Texas, Governor John Connally and President Kennedy were shot and suffering from gunshot wounds. During this chaos, Vice President Johnson and his wife Lady Bird were unaware of the tragic events that had taken place just a few cars ahead of them. President John F. Kennedy had been assassinated and rushed to Parkland Hospital. Upon his arrival at Parkland Hospital, Johnson and his wife were quickly rushed into a small cubical far from any doors or windows and kept there for their safety. After waiting twenty-five minuets, the presidential staff informed Johnson...

Words: 634 - Pages: 3

Premium Essay

Ruby Bridges: An Example Of A Hero

...someone that stands up for equal rights. A hero could be someone who serves in our military. Though now, I realize that any ordinary person like you and I could be a hero. Just imagine, having the glory from saving someone’s life. Do you think you could pull it off? First, let’s explain what a hero is. A hero is someone who cares about others and is willing to help them. They are the life rafts for our ocean of danger. In our world, there are many examples of heroic people. One example of a hero is Ruby Bridges. Do you know who she is? Bridges, born in 1954, was the first black child to go to an all-white school. At age 6, she passed a specific test that allowed her to attend the William Frantz School in New Orleans. Only six kids passed, so she must be a fountain of knowledge. This helped continue the Civil Rights Action. When she arrived at the school, Federal Marshals had to protect her. People threw objects. People were yelling. Barricades were set up. It was so chaotic that Ruby had to be kept in the principal’s office...

Words: 705 - 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