Skip to content
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

Tyler Ross #154

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions final_prep/annotations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really strong annotations! Good use of technical vocab, too ☺️

# Build a Bear

def build_a_bear(name, age, fur, clothes, special_power)
greeting = "Hey partner! My name is #{name} - will you be my friend?!"
demographics = [name, age]
power_saying = "Did you know that I can #{special_power}?"
built_bear = {
'basic_info' => demographics,
'clothes' => clothes,
'exterior' => fur,
'cost' => 49.99,
'sayings' => [greeting, power_saying, "Goodnight my friend!"],
'is_cuddly' => true,
def build_a_bear(name, age, fur, clothes, special_power) # Method taking in 5 parameters
greeting = "Hey partner! My name is #{name} - will you be my friend?!" #Variable greeting with interpolated name
demographics = [name, age] #Variable demographics set to array of name and age
power_saying = "Did you know that I can #{special_power}?" #Variable power saying set to string with interpolated special power
built_bear = { # Hash with 6 key:value pairs
'basic_info' => demographics, #Key basic info with value of array variable demographics
'clothes' => clothes,# Key clothes set to passed value from clothes parameter
'exterior' => fur,# Key exterior set to passed value from fur parameter
'cost' => 49.99, #key cost set to value 49.99
'sayings' => [greeting, power_saying, "Goodnight my friend!"],#Key sayings with value set to array of variable greeting, variable power saying, and string
'is_cuddly' => true, #Key is cuddly with value set to boolean
}
return built_bear
return built_bear #return hash built bear
end

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('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares') #Calls method build a bear
build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in') #Calls method build a bear


# FizzBuzz

def fizzbuzz(num_1, num_2, range)
(1..range).each do |i|
if i % num_1 === 0 && i % num_2 === 0
def fizzbuzz(num_1, num_2, range) #Method fizzbuzz taking in 3 parameters
(1..range).each do |i| #From one to value of parameter range, with counter
if i % num_1 === 0 && i % num_2 === 0 # If counter is evenly divisble into both parameter values output fizzbuzz to console
puts 'fizzbuzz'
elsif i % num_1 === 0
elsif i % num_1 === 0 # If counter is evenly divisble into first paramter value output fizz to console
puts 'fizz'
elsif i % num_2 === 0
elsif i % num_2 === 0 # If counter is evenly divisble into second paramter value output buzz to console
puts 'buzz'
else
else #If counter is not evenly divisble into either value, output counter value to console
puts i
end
end
end

fizzbuzz(3, 5, 100)
fizzbuzz(5, 8, 400)
fizzbuzz(3, 5, 100) #Call method fizzbuzz with 3 parameters
fizzbuzz(5, 8, 400) #Call method fizzbuzz again with 3 different parameters
94 changes: 80 additions & 14 deletions final_prep/mod_zero_hero.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,62 @@
# 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 = "Blob"
special_ability = "amorphism"

# Declare two variables - greeting AND catchphrase
# greeting should be assigned to a string that uses interpolation to include the hero_name
# catchphrase should be assigned to a string that uses interpolation to include the special_ability

greeting = "Ahhh what am I?"
catchphrase = "Couldn't I at least be non-newtonian?"

# Declare two variables - power AND energy - set to integers
power = 30
energy = 2

# Declare two variables - full_power AND full_energy
# full_power should multiply your current power by 500
# full_energy should add 150 to your current energy
full_power = power * 500
full_energy = energy + 150

# Declare two variables - is_human and identity_concealed - assigned to booleans

is_human = false
identitity_concealed = false

# Declare two variables - arch_enemies AND sidekicks
# arch_enemies should be an array of at least 3 different enemy strings
# sidekicks should be an array of at least 3 different sidekick strings

arch_enemies = ["Sidewalk Gum", "Photo ID", "Gutters" ]
sidekicks = ["Large Tupperware", "Wheel Barrow", "Hydrophilic Coating" ]
# Print the first sidekick to your terminal
puts sidekicks[0]

# Print the last arch_enemy to the terminal
puts arch_enemies[2]

# Write some code to add a new arch_enemy to the arch_enemies array

arch_enemies.push "Thirsty Seagull"
# Print the arch_enemies array to terminal to ensure you added a new arch_enemey

puts 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

puts 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)
if danger_level > 50
puts bad_excuse
elsif danger_level > 10 && danger_level <=50
puts save_the_day
else
puts "Meh. Hard pass."
end
end

# 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
Expand All @@ -47,6 +69,9 @@
# 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."
assess_situation(99, announcement, excuse)
assess_situation(21, announcement, excuse)
assess_situation(3, announcement, excuse)

# Declare a new variable - scary_monster - assigned to an hash with the following key/values
# - name (string)
Expand All @@ -55,18 +80,59 @@
# - citiesDestroyed (array)
# - luckyNumbers (array)
# - address (hash with following key/values: number , street , state, zip)
scary_monster = {
name: "Blarg",
smell: "Copper and Gardenia",
weight: 312,
citiesDestroyed: ["Carmel, IN", "Elizabeth Township, NJ"],
luckyNumbers: [7, 13, 21],
address: {
number: 515,
street: "Walla Walla Way",
state: "Washington",
zip: 12345
}
}


# 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
@@arch_nemesis = "The Syntax Error"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd advise making these instance variables - with only 1 @ and inside the initialize method.

@@power_level = 100
@@energy_level = 50
def initialize (name, super_power, age)
@name = name#= "The Sloth"
@super_power = super_power#= "Super slow"
@age = age #= 31

end

def say_name
puts @name
end

def maximize_energy
@@energy_level = 1000
end

def gain_power(power)
@@power_level += power
end
end

thunder_fingers = SuperHero.new("Thunder Fingers", "Fast typing", 24)
google_master = SuperHero.new("Google Master", "The first google search is always right", 34)

thunder_fingers.say_name
google_master.say_name
# - 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
Expand All @@ -77,8 +143,8 @@

# Reflection
# What parts were most difficult about this exerise?

# Nested hashes took some time to figure out. Static vs dynamic class variables was new as well.
# What parts felt most comfortable to you?

#Syntax is starting to sink in. I don't think I had to look up basic formatting questions here.
# What skills do you need to continue to practice before starting Mod 1?

#I dont have a good grasp of which topics I don't know until I am confronted by a new topic/issue.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's totally reasonable right now - this is brand new! And this is why you have instructors with a thoughtful curriculum - they will put challenges in front of you that you need to tackle, and provide feedback on how you're progressing.