forked from turingschool-examples/backend_mod_1_prework
-
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
Tyler Ross #154
Open
Tross0208
wants to merge
7
commits into
turingschool:main
Choose a base branch
from
Tross0208: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
Tyler Ross #154
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3b4e2cb
Add section 1
Tross0208 d4443a3
Add section 2
Tross0208 7fdc8a0
Add section3
Tross0208 7e3eab9
Add section4
Tross0208 7ac5743
Add mod zero hero, annotations
Tross0208 b449858
Revise mod zero hero
Tross0208 e893abe
Add Read me
Tross0208 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"hello".class | ||
|
||
"world".class |
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class GoodDog | ||
end | ||
|
||
sparky = GoodDog.new | ||
|
||
|
||
module Speak | ||
def speak(sound) | ||
puts sound | ||
end | ||
end | ||
|
||
class GoodDog | ||
include Speak | ||
end | ||
|
||
class HumanBeing | ||
include Speak | ||
end | ||
|
||
sparky = GoodDog.new | ||
sparky.speak("Arf!") | ||
bob = HumanBeing.new | ||
bob.speak("Hello!") | ||
|
||
|
||
module Speak | ||
def speak(sound) | ||
puts "#{sound}" | ||
end | ||
end | ||
|
||
class GoodDog | ||
include Speak | ||
end | ||
|
||
class HumanBeing | ||
include Speak | ||
end | ||
|
||
puts "---GoodDog ancestors---" | ||
puts GoodDog.ancestors | ||
puts '' | ||
puts "---HumanBeing ancestors---" | ||
puts HumanBeing.ancestors |
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class GoodDog | ||
attr_accessor :name, :height, :weight | ||
|
||
def initialize(n, h, w) | ||
@name = n | ||
@height = h | ||
@weight = w | ||
end | ||
|
||
def speak | ||
"#{name} says arf!" | ||
end | ||
|
||
def change_info(n, h, w) | ||
self.name = n | ||
self.height = h | ||
self.weight = w | ||
end | ||
|
||
def info | ||
"#{self.name} weighs #{self.weight} and is #{self.height} tall." | ||
end | ||
end | ||
|
||
|
||
sparky = GoodDog.new('Sparky', '12 inches', '10 lbs') | ||
puts sparky.info | ||
|
||
sparky.change_info('Spartacus', '24 inches', '45 lbs') | ||
puts sparky.info | ||
|
||
puts sparky.weight |
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class GoodDog | ||
def initialize(name) | ||
@name = name | ||
end | ||
|
||
def speak | ||
"#{@name} says arf!" | ||
end | ||
|
||
def name | ||
@name | ||
end | ||
|
||
def name=(name) | ||
@name = name | ||
end | ||
|
||
end | ||
|
||
sparky = GoodDog.new("Sparky") | ||
puts sparky.speak | ||
puts sparky.name | ||
sparky.name = "Spartacus" | ||
puts sparky.name | ||
|
||
|
||
fido = GoodDog.new("Fido") | ||
puts fido.speak | ||
|
||
|
||
|
||
|
||
#Want to keep this example, continuing example on ex3-2.rb |
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Student | ||
attr_accessor :first_name, :last_name, :primary_phone_number | ||
|
||
def introduction(target) | ||
puts "Hi #{target}, I'm #{first_name}!" | ||
end | ||
|
||
def favorite_number | ||
7 | ||
end | ||
|
||
end | ||
|
||
frank = Student.new | ||
frank.first_name = "Frank" | ||
frank.introduction('Katrina') | ||
puts "Frank's favorite number is #{frank.favorite_number}." |
This file contains 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,5 +1,34 @@ | ||
# Create a person class with at least 2 attributes and 2 behaviors. | ||
# Create a person class with at least 2 attributes and 2 behaviors. | ||
# Call all person methods below the class and print results | ||
# to the terminal that show the methods in action. | ||
|
||
# YOUR CODE HERE | ||
class Person | ||
def initialize (name, age, healthy) | ||
@name = name | ||
@age = age | ||
@healthy = healthy | ||
end | ||
|
||
def birthday | ||
@age += 1 | ||
end | ||
|
||
def age | ||
@age | ||
end | ||
|
||
def poisoned | ||
@healthy = false | ||
end | ||
|
||
def healthy | ||
@healthy | ||
end | ||
end | ||
|
||
tyler = Person.new("Tyler", 31, true) | ||
p tyler | ||
tyler.birthday | ||
puts tyler.age | ||
tyler.poisoned | ||
puts tyler.healthy |
This file contains 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,22 +1,41 @@ | ||
## Section 4 Reflection | ||
|
||
1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? | ||
It felt better in some respects, worse in others. 25 minutes is too small a time for me, as it can take me a while to figure out where I left off. | ||
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. Good reflection! Totally ok to "up" that time to something that feels better for you. (BTW I am the same - set my timer for 50 then take a little longer of a break) |
||
|
||
1. Regarding the work you did around setting intentions in Step 1 of the Pomodoro technique - how did that go? Were you surprised by anything (did you find yourself way more focused than you realized, more distracted that you thought you'd be, estimating times accurately or totally off, etc)? | ||
Setting intentions was effective. The intention was usually a very small task due to the time limit, and made it easy to focus on and track progress. | ||
|
||
1. In your own words, what is a Class? | ||
A class is a set of common qualities. | ||
|
||
1. What is an attribute of a Class? | ||
An attribute is a piece of data belonging to a class. | ||
|
||
1. What is behavior of a Class? | ||
A behavior is an action taken by or done to a class. | ||
|
||
1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors: | ||
|
||
```rb | ||
class Dinner | ||
def initialize (food, beverage) | ||
@food = food | ||
@beverage = beverage | ||
end | ||
|
||
def eat_food | ||
@food = false | ||
end | ||
|
||
def drink_beverage | ||
@beverage = false | ||
end | ||
end | ||
|
||
``` | ||
|
||
1. How do you create an instance of a class? | ||
`name_of_object = Class.new(attributes)` | ||
|
||
1. What questions do you still have about classes in Ruby? | ||
1. What questions do you still have about classes in Ruby? |
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.
You'll generally want to avoid using single letter variables in Ruby and most modern languages. The reason is readability for other devs, and it's simply not convention. In this case, I totally see where they came from and it makes sense enough, but definitely not a habit you want to get into.