-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Becky Nisttahuz #157
base: main
Are you sure you want to change the base?
Becky Nisttahuz #157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,15 @@ | |
# Use the # to create a new comment | ||
|
||
# Build a Bear | ||
|
||
# Create a function called build_a_bear that takes 6 arguments: name, age, fur, clothes, special_power | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! And in Ruby, they'll be referred to as methods! |
||
def build_a_bear(name, age, fur, clothes, special_power) | ||
#greeting should be a string that has the name argument | ||
greeting = "Hey partner! My name is #{name} - will you be my friend?!" | ||
#demographics should an array that has elements: name and age | ||
demographics = [name, age] | ||
#power_saying should be a string that includes the special_power argument | ||
power_saying = "Did you know that I can #{special_power}?" | ||
#built_bearshould be a hash with elements: basic_info, clothes, exterior, cost, sayings, is_cuddly | ||
built_bear = { | ||
'basic_info' => demographics, | ||
'clothes' => clothes, | ||
|
@@ -16,28 +20,47 @@ def build_a_bear(name, age, fur, clothes, special_power) | |
'sayings' => [greeting, power_saying, "Goodnight my friend!"], | ||
'is_cuddly' => true, | ||
} | ||
#return build_bear | ||
return built_bear | ||
#end | ||
end | ||
|
||
#test cases: | ||
#build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') | ||
build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') | ||
#build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') | ||
build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') | ||
|
||
|
||
# FizzBuzz | ||
|
||
#Create a function called fizzbuzz that takes 3 argument: num_1, num_2, range | ||
def fizzbuzz(num_1, num_2, range) | ||
#loop with .each do instead of for loop | ||
(1..range).each do |i| | ||
#Use modulo operator to get the remainder of the division i on num-1 | ||
#if i modulo num_1 triple equals 0 AND i modulo num_2 triple equals 0 | ||
if i % num_1 === 0 && i % num_2 === 0 | ||
#print "fizzbuzz" | ||
puts 'fizzbuzz' | ||
#else if i modulo num_1 triple equals 0 | ||
elsif i % num_1 === 0 | ||
#print "fizz" | ||
puts 'fizz' | ||
#else if i modulo num_2 triple equals 0 | ||
elsif i % num_2 === 0 | ||
#print "buzz" | ||
puts 'buzz' | ||
#otherwise | ||
else | ||
#print i | ||
puts i | ||
#end | ||
end | ||
#end | ||
end | ||
#end | ||
end | ||
|
||
#test cases | ||
#fizzbuzz(3, 5, 100) | ||
fizzbuzz(3, 5, 100) | ||
fizzbuzz(5, 8, 400) | ||
#fizzbuzz(5, 8, 400) | ||
fizzbuzz(5, 8, 400) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,72 @@ | ||
# Challenge - See if you can follow the instructions and complete the exercise in under 30 minutes! | ||
|
||
# Declare two variables - hero_name AND special_ability - set to strings | ||
|
||
hero_name = "Learny" | ||
special_ability = "Instant learning" | ||
# Declare two variables - greeting AND catchphrase | ||
# greeting should be assigned to a string that uses interpolation to include the hero_name | ||
greeting = " Hello I am #{hero_name}!" | ||
# catchphrase should be assigned to a string that uses interpolation to include the special_ability | ||
|
||
catchphrase = "#{special_ability} will save the world! " | ||
# Declare two variables - power AND energy - set to integers | ||
|
||
power = 100 | ||
energy = 90 | ||
# Declare two variables - full_power AND full_energy | ||
# full_power should multiply your current power by 500 | ||
full_power = power * 500 | ||
# full_energy should add 150 to your current energy | ||
|
||
full_energy = energy + 150 | ||
# Declare two variables - is_human and identity_concealed - assigned to booleans | ||
|
||
is_human = true | ||
identity_concealed = false | ||
|
||
# Declare two variables - arch_enemies AND sidekicks | ||
# arch_enemies should be an array of at least 3 different enemy strings | ||
arch_enemies = ['Dum', 'Idot', 'Lem'] | ||
# sidekicks should be an array of at least 3 different sidekick strings | ||
|
||
sidekicks = ['Superman', 'Batman', 'Wonderwoman'] | ||
# Print the first sidekick to your terminal | ||
|
||
p sidekicks[0] | ||
# Print the last arch_enemy to the terminal | ||
|
||
p arch_enemies[2] | ||
# Write some code to add a new arch_enemy to the arch_enemies array | ||
|
||
arch_enemies << 'Stoop' | ||
# Print the arch_enemies array to terminal to ensure you added a new arch_enemey | ||
|
||
p arch_enemies | ||
# Remove the first sidekick from the sidekicks array | ||
|
||
sidekicks.shift | ||
# Print the sidekicks array to terminal to ensure you added a new sidekick | ||
|
||
p sidekicks | ||
# Create a function called assess_situation that takes three arguments - danger_level, save_the_day, bad_excuse | ||
# - danger_level should be an integer | ||
# - save_the_day should be a string a hero would say once they save the day | ||
# - save_the_day should be a string a hero would say once they save the day | ||
# - bad_excuse should be a string a hero would say if they are too afraid of the danger_level | ||
def assess_situation(danger_level, save_the_day, bad_excuse) | ||
danger = 0 | ||
announcement = 'I just saved the day!' | ||
excuse = 'I will let Superman have a chance to save the day today.' | ||
|
||
#puts "How dangerous is it?" | ||
#danger_measurement = $stdin.gets.chomp.to_i | ||
# Your function should include an if/else statement that meets the following criteria | ||
# - Danger levels that are above 50 are too scary for your hero. Any danger level that is above 50 should result in printing the bad_excuse to the terminal | ||
# - Anything danger_level that is between 10 and 50 should result in printing the save_the_day string to the terminal | ||
# - If the danger_level is below 10, it means it is not worth your time and should result in printing the string "Meh. Hard pass." to the terminal. | ||
if danger > 50 | ||
puts "'I just saved the day!'" | ||
elsif danger >= 10 && danger <= 50 | ||
puts "'I will let Superman have a chance to save the day today.'" | ||
else | ||
puts "Meh. Hard pass." | ||
end | ||
end | ||
|
||
#Test Cases | ||
announcement = 'Never fear, the Courageous Curly Bracket is here!' | ||
excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' | ||
# assess_situation(99, announcement, excuse) > Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' | ||
#assess_situation(21, announcement, excuse) > should print - 'Never fear, the Courageous Curly Bracket is here!' | ||
#assess_situation(3, announcement, excuse) > should print - "Meh. Hard pass." | ||
#announcement = 'I just saved the day!' | ||
#excuse = 'I will let Superman have a chance to save the day today.' | ||
assess_situation(99, announcement, excuse) #> Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' | ||
assess_situation(21, announcement, excuse) #> should print - 'Never fear, the Courageous Curly Bracket is here!' | ||
assess_situation(3, announcement, excuse) #> should print - "Meh. Hard pass." | ||
|
||
# Declare a new variable - scary_monster - assigned to an hash with the following key/values | ||
# - name (string) | ||
|
@@ -56,29 +76,78 @@ | |
# - luckyNumbers (array) | ||
# - address (hash with following key/values: number , street , state, zip) | ||
|
||
scary_monster = { | ||
"name" => '', | ||
"smell" => '', | ||
"weight" => 400, | ||
"cities_destroyed" => ['Paris', 'Milan', 'Texas'], | ||
"lucky_numbers" => [1, 2, 3, 4], | ||
"address" => { | ||
"number" => 10, | ||
"street" => 'King', | ||
"state" => 'CO', | ||
"zip" => 80301 | ||
} | ||
} | ||
|
||
|
||
# Create a new class called SuperHero | ||
# - Your class should have the following DYNAMIC values | ||
# - name | ||
# - name | ||
# - super_power | ||
# - age | ||
# - age | ||
# - Your class should have the following STATIC values | ||
# - arch_nemesis, assigned to "The Syntax Error" | ||
# - power_level = 100 | ||
# - energy_level = 50 | ||
|
||
# - energy_level = 50 | ||
class SuperHero | ||
attr_accessor :name, :super_power, :age | ||
attr_reader :arch_nemesis, :power_level, :energy_level | ||
|
||
def initialize(name, super_power, age, power_level, energy_level) | ||
@name = name | ||
@super_power = super_power | ||
@age = age | ||
@arch_nemesis = arch_nemesis | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For lines 111-113, check the directions written up on lines 99 about these needing to be static values and adjust your solution. Let me know if you need help or have questions about that. |
||
@power_level = power_level | ||
@energy_level = energy_level | ||
end | ||
# - Create the following class methods | ||
# - say_name, should print the hero's name to the terminal | ||
# - maximize_energy, should update the energy_level to 1000 | ||
# - gain_power, should take an argument of a number and INCREASE the power_level by that number | ||
|
||
def say_name | ||
puts "His name is #{name}" | ||
end | ||
|
||
def maximize_energy | ||
@energy_level = 1000 | ||
end | ||
|
||
def gain_power(number) | ||
@power_level += number | ||
puts "He gained power to #{power_level}" | ||
end | ||
end | ||
# - Create 2 instances of your SuperHero class | ||
|
||
|
||
learny = SuperHero.new("learny", "Instant learning", 50, 10, 20) | ||
p learny.name | ||
p learny.super_power | ||
p learny.age | ||
p learny.power_level | ||
p learny.energy_level | ||
learny.say_name | ||
learny.maximize_energy | ||
learny.gain_power(10) | ||
p learny.name | ||
p learny.super_power | ||
p learny.age | ||
p learny.power_level | ||
p learny.energy_level | ||
# Reflection | ||
# What parts were most difficult about this exerise? | ||
|
||
#Remembering all the technical words and syntax was very difficult. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IT IS! Time and practice will get you there! |
||
# What parts felt most comfortable to you? | ||
|
||
#The firsdt part of the exercise was the most easiest to me. | ||
# What skills do you need to continue to practice before starting Mod 1? | ||
|
||
#I need to practice, practice and practice! I defenitly need to get more comfortable qith the wording and understanding the meaning of each line of pseudocode. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your annotations looked solid, which makes me believe you do have a good technical understanding. That's awesome! So keep focusing on the technical vocabulary you read and use. More practice will help, and when you are completely immersed in Mod 1, you'll have LOTS of practice :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#Print sentence 'I will now calculate Felipe's pay:' | ||
puts "I will now calculate Felipe's sales:" | ||
#Print the calculation in curly brackets | ||
puts "Felipe's sales on weekdays for a month #{30 + 20 - 3 % 5 / 4}" | ||
#Print the result of the calculation in curly brackets | ||
puts "Felipe's sales on weekends for a month #{3 + 76 / 7}" | ||
#Print sentence 'Now let's count his expenses:' | ||
puts "Now let's count his expenses:" | ||
#Print result of the calculation | ||
puts 4 + 5 + 7 - 8 / 12 | ||
#Print question. Boolean | ||
puts "It is true that #{30 + 20 - 3 % 5 / 4} + #{3 + 76 / 7} > #{ 4 + 5 + 7 - 8 / 12}?" | ||
#Calculate and print the boolean answer. Either true or false | ||
puts (30 + 20 - 3 % 5 / 4) + (3 + 76 / 7) > 4+ 5 + 7 - 8 / 12 | ||
#Print question and answer for the calculation in curly brackets | ||
puts "What is 50 + 13? #{50 + 13}" | ||
#Print question and answer for the calculation in curly brackets | ||
puts "What is 4 + 5 + 7 - 8 / 12? #{4 + 5 + 7 - 8 / 12}" | ||
#Print sentence 'Oh, now I understand.' | ||
puts "Oh, now I understand." | ||
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false | ||
puts "Is it greater? #{50 + 13 > 4 + 5 + 7 - 8 / 12}" | ||
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false | ||
puts "Is it greater or equal? #{50 + 13 >= 4 + 5 + 7 - 8 / 12}" | ||
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false | ||
puts "Is it less or equal? #{50 + 13 <= 4 + 5 + 7 - 8 / 12}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# puts "Hello World!" | ||
#puts "Hello Again" | ||
#puts "I like typing this." | ||
#puts "This is fun." | ||
puts "Yay! Printing." | ||
#puts "I'd much rather you 'not'." | ||
#puts 'I "said" do not touch this.' | ||
#puts "Making my script print another line" | ||
# Making my script print only one of the lines: I use # at the beggining of each line but one | ||
#puts "This is another line. What does putting a # character at the beginning of the line do? It makes it into a comment. It won't print. | ||
|
||
|
||
#Study drills | ||
#1. # Making my script print only one of the lines: I use # at the beggining of each line but one | ||
#puts "This is another line. #What does putting a # character at the beginning of the line do? It makes it into a comment. It won't print. | ||
#2. I made my script print only one of the lines by using the octothorpecharacter at the beginning of each line | ||
#3. It comments out the line. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# A comment, this is so you can read your program later. | ||
# Anything after the # is ignored by ruby. | ||
|
||
puts "I could have code like this." # and the comment after is ignored | ||
|
||
# You can also use a comment to "disable" or comment out a piece of code: | ||
# puts "This won't run." | ||
|
||
puts "This will run." | ||
|
||
|
||
|
||
|
||
#Study Drills | ||
#1. I was right about what the octothorpe character does at the beginning of a line. It makes the line into a comment that won't print. | ||
#2. I reviewed each line going backward. | ||
#3. I fixed a couple of mistakes. | ||
#4. I read out loud what I typed and did not find more errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWESOME job with these annotations!