forked from turingschool-examples/backend_mod_1_prework
-
Notifications
You must be signed in to change notification settings - Fork 176
Rin Fabian #165
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
Open
Rinplz
wants to merge
32
commits into
turingschool:main
Choose a base branch
from
Rinplz:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Rin Fabian #165
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e1bc631
intro 1 complete
c8fa6b6
example 2 complete
b9df8fd
example 3 complete
86c72ef
complete example 4
cabe253
add explanation of each line
5a7e4e6
add example 5
57b8295
complete example 5
0955b8d
create example 6
f49e03d
complete example 6
fdb6562
create example 7
b19ff5c
complete example 7
d718049
create example 8
e2566ac
create example 11
dae7b68
complete example 11
8e2a983
complete strings exercise
3db54a3
complete numbers exercise.
cbfa275
complete booleans activity
bf88908
complete variables exercise
2f5bac6
complete interpolation exercise
d8f690a
complete loops exercise
53379ba
complete reflections
6d3d80d
if statements exercise complete
7ad5334
if and conditionals lessons complete
0dada40
Add section 2 work
df6c7a8
complete section 3
e33b0d5
complete dog and burrito exercises
2ace9a9
edited burrito and completed person
07983be
complete reflections
517dcdb
complete final prep
e9e0ac5
Update README.md
Rinplz 0e31fbf
Update README.md
Rinplz f22957c
Update README.md
Rinplz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,66 @@ | ||
| # 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 = 'The Flash' | ||
| special_ability = 'Super Speed' | ||
|
|
||
| # 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 = "I'm #{hero_name}. I'm the fastest man alive." | ||
| catchphrase = "You can't keep up with me. I've got #{special_ability}" | ||
|
|
||
| # Declare two variables - power AND energy - set to integers | ||
| power = 200 | ||
| energy = 50 | ||
|
|
||
| # 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 = 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 = ['Captain Cold', 'Gorila Grodd', 'Reverse Flash'] | ||
| # sidekicks should be an array of at least 3 different sidekick strings | ||
|
|
||
| sidekicks = ['Kid Flash', 'Impulse', 'Wally West'] | ||
| # Print the first sidekick to your terminal | ||
|
|
||
| p sidekicks.first | ||
| # Print the last arch_enemy to the terminal | ||
|
|
||
| p arch_enemies.last | ||
| # Write some code to add a new arch_enemy to the arch_enemies array | ||
| arch_enemies.push('Mirror Master') | ||
|
|
||
| # 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) | ||
| if danger_level > 50 | ||
| p bad_excuse | ||
| elsif danger_level === (10..50) | ||
|
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. If danger_level is 25, this line of code will return You should not be using the |
||
| p save_the_day | ||
| else | ||
| p "Meh. Hard Pass." | ||
| end | ||
| end | ||
|
|
||
| bad_excuse = "I think I left the oven on at home." | ||
| save_the_day = "This'll be over quick." | ||
|
|
||
| assess_situation(99,save_the_day,bad_excuse) | ||
| assess_situation(21,save_the_day,bad_excuse) | ||
| assess_situation(3,save_the_day,bad_excuse) | ||
|
|
||
| # 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 | ||
|
|
@@ -55,17 +81,52 @@ | |
| # - citiesDestroyed (array) | ||
| # - luckyNumbers (array) | ||
| # - address (hash with following key/values: number , street , state, zip) | ||
| scary_monster = { | ||
| name: 'Jawful', | ||
| smell: 'shark', | ||
| weight: '458', | ||
| citiesDestroyed: ['New Jersey, Maine, Miami'], | ||
| luckyNumbers: [5, 13, 27], | ||
| address: {number: 436, street: 'Lorelaine', state: 'Florida', zip: '32116'} | ||
| } | ||
|
|
||
|
|
||
| # 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 | ||
|
|
||
| arch_nemesis = "The Syntax Error" | ||
| power_level = 100 | ||
| energy_level = 50 | ||
|
|
||
| def initialize(name, super_power, age) | ||
| @name = name | ||
| @super_power = super_power | ||
| @age = age | ||
| end | ||
|
|
||
| def say_name | ||
| p @name | ||
| end | ||
|
|
||
| def maximize_energy | ||
| energy_level = 1000 | ||
| end | ||
|
|
||
| def gain_power(energy_level) | ||
| power_level = power_level * energy_level | ||
| end | ||
|
|
||
| end | ||
|
|
||
| # - Create the following class methods | ||
| # - say_name, should print the hero's name to the terminal | ||
|
|
@@ -74,11 +135,18 @@ | |
|
|
||
| # - Create 2 instances of your SuperHero class | ||
|
|
||
| awesome_array = SuperHero.new('Awesome Array', 'teleporting', 28) | ||
| mr_float = SuperHero.new('Mr. Float', 'flight', 35) | ||
|
|
||
|
|
||
| # Reflection | ||
| # What parts were most difficult about this exerise? | ||
| #hashes gave me the most trouble | ||
|
|
||
|
|
||
| # What parts felt most comfortable to you? | ||
| #creating variables, making methods, printing | ||
|
|
||
| # What skills do you need to continue to practice before starting Mod 1? | ||
|
|
||
| #learning the extensions for manipulating data types like arrays, and | ||
| #studying the syntax for hashes and classes | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These are called parameters,.Arguments are the values that you actually pass into the method (i.e. on lines 66 and 68). Parameters and arguments are 2 sides of the same coin, so to speak.