class Person:

    def __init__(self, name):
        self.name = name

    def say_hello(self):
        print("Hello, ", self.name)

p1 = Person("Allan")
p1.say_hello()

p2 = Person("John")
p2.say_hello()

class Classroom:

    def __init__(self):
        self._people = []

    def add_person(self, person):
        self._people.append(person)

    def remove_person(self, person):
        self._people.remove(person)

    def greet(self):
        for person in self._people:
            person.say_hello()

class Person:

    def __init__(self, name):
        self.name = name

    def say_hello(self):
        print("Hello, ", self.name)

room = Classroom()
room.add_person(Person("Scott"))
room.add_person(Person("John"))
room.add_person(Person("Paul"))
room.greet()

Create classroom and some encapsulation
Create classroom and some encapsulation

+ class Classroom:
+ 
+     def __init__(self):
+         self._people = []
+ 
+     def add_person(self, person):
+         self._people.append(person)
+ 
+     def remove_person(self, person):
+         self._people.remove(person)
+ 
+     def greet(self):
+         for person in self._people:
+             person.say_hello()
+ 
  class Person:
  
      def __init__(self, name):
          self.name = name
  
      def say_hello(self):
          print("Hello, ", self.name)
  
- p1 = Person("Allan")
- p1.say_hello()
+ room = Classroom()
+ room.add_person(Person("Scott"))
+ room.add_person(Person("John"))
+ room.add_person(Person("Paul"))
+ room.greet()
  
- p2 = Person("John")
- p2.say_hello()
- 
Create classroom and some encapsulation
## Code Before:
class Person:

    def __init__(self, name):
        self.name = name

    def say_hello(self):
        print("Hello, ", self.name)

p1 = Person("Allan")
p1.say_hello()

p2 = Person("John")
p2.say_hello()

## Instruction:
Create classroom and some encapsulation
## Code After:
class Classroom:

    def __init__(self):
        self._people = []

    def add_person(self, person):
        self._people.append(person)

    def remove_person(self, person):
        self._people.remove(person)

    def greet(self):
        for person in self._people:
            person.say_hello()

class Person:

    def __init__(self, name):
        self.name = name

    def say_hello(self):
        print("Hello, ", self.name)

room = Classroom()
room.add_person(Person("Scott"))
room.add_person(Person("John"))
room.add_person(Person("Paul"))
room.greet()
