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

Becky Nisttahuz #157

Open
wants to merge 5 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
2 changes: 1 addition & 1 deletion section2/exercises/ex6_sec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ def divide(a, b)
puts "Is my formula working?"


#5. I removed the word return and see if the script still works.
#5. I removed the word return and see if the script still works. It does!
21 changes: 21 additions & 0 deletions section4/ex1_sec4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Exercises The Object Model
1. How do we create an object in Ruby? Give an example of the creation of an object.

class SmartAnimal
class SmartAnimal
end

crow = SmartAnimal.new


2. What is a module? What is its purpose? How do we use them with our classes? Create a module for the class you created in exercise 1 and include it properly.
A module is a collection of reusable behaviors that can be use in other classes. We use them with our classes by using the include method.

module Communicate
end

class SmartAnimal
include Communicate
end

crow = SmartAnimal.new
56 changes: 56 additions & 0 deletions section4/ex2_sec4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#Exercises:
#1. Create a class called MyCar.

class MyCar
attr_accessor :color
attr_reader :year

def initialize(year, color, model)
@year = year
@color = color
@model = model
@speed = 0
end

def speeds(number)
@speed += number
puts "Going too fast!"
end

def brakes(number)
@speed -= number
puts "Keep slowing down"
end

def speed
puts "You are going #{@speed} miles per hour."
end

def shut_car_off
@speed = 0
puts "Please turn the car off"
end

def spray_paint(color)
self.color = color
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason you used self here??

Copy link
Author

Choose a reason for hiding this comment

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

Because we already have the attr_accessor :color.

puts "New #{color} color for your car!"
end
end

toyota = MyCar.new(1991, 'gray', 'camri')
puts toyota.color
toyota.spray_paint('black')
puts toyota.color
#toyota.speeds(80)
#toyota.speed
#toyota.brakes(70)
#toyota.speed
#toyota.shut_car_off
#toyota.speed
#toyota.color = 'green'
#puts toyota.color
#puts toyota.year


#2. I added an accessor method to the MyCar class to change and view the color of your car.Then added an accessor method that allows me to view, but not modify, the year of the car.
#3. I create a method called spray_paint that can be called on an object and will modify the color of the car.
23 changes: 22 additions & 1 deletion section4/exercises/burrito.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Add the following methods to this burrito class and
# Add the following methods to this burrito class and
# call the methods below the class:
# 1. add_topping
# 2. remove_topping
Expand All @@ -11,9 +11,30 @@ def initialize(protein, base, toppings)
@base = base
@toppings = toppings
end

def add_topping(another_topping)
toppings.push(another_topping)
puts "Now you have more toppings: #{toppings}"
end

def remove_topping(undesired_topping)
toppings.delete(undesired_topping)
puts "Now you have less toppings: #{toppings}"
end

def change_protein(different_protein)
@protein = (different_protein)
puts "You want #{protein} as your protein? Sure."
end
end

dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"])
p dinner.protein
p dinner.base
p dinner.toppings
dinner.add_topping("onions")
dinner.remove_topping("cheese")
dinner.change_protein("chicken")
p dinner.protein
p dinner.base
p dinner.toppings
9 changes: 8 additions & 1 deletion section4/exercises/dog.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# In the dog class below, write a `play` method that makes
# the dog hungry. Call that method below the class, and
# the dog hungry. Call that method below the class, and
# print the dog's hunger status.

class Dog
Expand All @@ -19,6 +19,11 @@ def bark
def eat
@hungry = false
end

def chase_ball
@hungry = true
p "Fido is so hungry!"
end
end

fido = Dog.new("Bernese", "Fido", 4)
Expand All @@ -28,3 +33,5 @@ def eat
p fido.hungry
fido.eat
p fido.hungry
fido.chase_ball
p fido.hungry
60 changes: 59 additions & 1 deletion section4/exercises/person.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# 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
attr_reader :age, :weight, :cook, :work
def initialize(age, weight)
@age = age
@weight = weight
@cook = true
@work = false
end

def have_birthday(older)
@age += older
puts "I am now #{age} years old"
end

def no_appetite(lost_weight)
@weight -= lost_weight
puts "I am never hungry so I lost some weight. Now I weight #{weight} pounds."
end

def cooks
@cook = true
puts "I love to cook #{cook}"
end

def works
@work = false
puts "I do currently work #{work}"
end
end

ana = Person.new(21, 130)
p ana.age
p ana.weight
p ana.cook
p ana.work
ana.have_birthday(10)
ana.no_appetite(9)
ana.cooks
ana.works
p ana.age
p ana.weight
p ana.cook
p ana.work

oliver = Person.new(40, 164)
p oliver.age
p oliver.weight
p oliver.cook
p oliver.work
oliver.have_birthday(1)
oliver.no_appetite(2)
oliver.cooks
oliver.works
p oliver.age
p oliver.weight
p oliver.cook
p oliver.work
67 changes: 66 additions & 1 deletion section4/reflection.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,87 @@

## Section 4 Reflection

1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique?
Time management is hard for me since I need to read not once, not twice but sometimes even three times the same information for me to be able to retain the information. I like the idea of having a timer to have a better flow with homework and learning in general. I just have to make sure I still learn what I need to to learn in that time sice I am learning while completing tasks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Turing can and will provide accommodations for students whose first language is not English and need extra time. I encourage you to advocate for that with your Mod 1 instructors early in the module if you'd like to have that!

Copy link
Author

Choose a reason for hiding this comment

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

Thank you! I will make sure I do that.


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)?
I was more distracted than expected. I think I just need more practice and getting use to idea of having a timer. I found that it added more pressure and I found myself not being able to focus very well. The more I tried it though, the better it got.

1. In your own words, what is a Class?
A Class is like a blueprint of an object. It defines its attributes and methods.

1. What is an attribute of a Class?
An attribute of a Class is a specific property of an object. Is the information the object holds.

1. What is behavior of a Class?
Behavior of a lass tells us how the Class will react. It is what an object is capable of doing.

1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors:

```rb

class CuteDog
attr_reader :name, :weight, :playful, :loud

def initialize(name, weight)
@name = name
@weight = weight
@playful = false
@loud = true
end

def older
@age += 10
puts "Simba is now #{age} old"
end

def bigger(weights_more)
@weight += weights_more
puts "The older he gets the bigger Simba gets. Last year he was weigthing #{weight} pounds"
end

def smaller(weights_less)
@weight -= weights_less
puts "After year 12, Simba started getting thiner, now he is #{weight} punds"
end

def barks
@loud = true
puts "Simba's bark is very loud #{loud}"
end

def plays
@playful = false
puts "Simba likes to play #{playful} "
end
end

simba = CuteDog.new("Simba", 70)
p simba.name
p simba.weight
p simba.playful
p simba.loud
simba.bigger(10)
simba.smaller(19)
simba.plays
simba.barks
p simba.name
p simba.weight
p simba.playful
p simba.loud
```

1. How do you create an instance of a class?
By calling the 'new' method on the class. Then is stored in a variable.

1. What questions do you still have about classes in Ruby?
I do have many questions but I am hoping the more I practice the more I will understand the basic questions. I am still trying to understand for example if there are other types of classes in Ruby?

- Have the time estimates matched up with your experience?
I definitely spent more time than I was expecting. I am the kind of learner that has to re-read things and have to practice over and over to learn well.

- When you sit down to start working, do you have a clear goal of what you want to accomplish and in how much time? If so, how aligned is that to what actually happens?
I do have a clear goal I want to accomplish when working on something. With coding however since I am just starting to learn the basics, it takes me longer than expected. I believe the more comfortable I get with the basics, the more I will be able to follow my time limits and goals.

1. What questions do you still have about classes in Ruby?
- How do you work best - in 2 hour blocks, 4 hour blocks, etc? Do you take breaks regularly? Do you have a system to hold yourself accountable to taking breaks?
I work best in smaller blocks of time. I do try to takes breaks as soon as start feeling I am not paying as much attention, or when I have to read over and over the same thing to understand it. I am actually looking for an alternative to a timer to take breaks. For now, I am using a timer.