#Attr Methods

# I worked on this challenge by myself

# I spent 2 hours on this challenge.

class NameData
  attr_accessor :name
  def initialize
  @name = "Lauren"
  end
end


class Greetings
  def initialize
    @namedata = NameData.new
  end

  def hello
    puts "Hello #{@namedata.name}! How wonderful to see you today."
  end

end

greet = Greetings.new
p greet.hello


# Reflection
=begin
Release 1: What are these methods doing?
- These methods are returning a person's name, age, and occupation. The first set of methods are reader methods while the second set "change_" are writer methods.
Release 1: How are they modifying or returning the value of instance variables?
- The writer methods are modifying the values by setting an argument, and pointing the instance variable to that (new) argument.

Release 2: What changed between the last release and this release?
- An attr_reader for age was added so that the age method does not have to be created.
Release 2: What was replaced?
- The age method was replaced with the attr_reader.
Release 2: Is this code simpler than the last?
- Yes, the age method was simplified to one line.

Release 3: What changed between the last release and this release?
- An attr_writer for age was added so that the writer method of change_my_age does not have to be created.
Release 3: What was replaced?
- The change_my_age method was replaced with the attr_writer:age
Release 3: Is this code simpler than the last?
- Yes, again, 3 lines of code was reduced to one line.

REFLECT

What is a reader method?
- Ruby restricts access to instant variables except through getter and setter methods. The reader method is also known as the "getter" method, its purpose is to return the value of a particular instance variable outside its class. With this method you cannot change it, you can only "read" it.

What is a writer method?
- Also known as the "setter" method, you can change the value of the instance variables outside of its class.

What do the attr methods do for you?
- The attr methods are used for declaring getters and setters for your object via the attr_reader and attr_writer. The attr_accessor method is a combination of these two methods.

Should you always use an accessor to cover your bases? Why or Why not?
- No because there would be some variables that you only want read and if they were also changeable, that could cause problems with data security and debugging.

What is confusing to you about these methods?
- I got a little confused between the difference between the writer method and attr_writer method for a second, and same with the reader. I just realized it's a way to access the method.
=end