Created
January 21, 2015 22:24
-
-
Save troyleach/20695c20e9dc2c0fcc55 to your computer and use it in GitHub Desktop.
screen cast 18, 19, and 20
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
| #screen cast 18, 19 and 20 | |
| # So I combined all these, I hope that is ok!! | |
| =begin | |
| Create a class called Person. | |
| Add methods to it that let you change the person’s age, occupation, and mood. | |
| Then add methods named age, occupation, and mood which give return values of the age, occupation, and mood respectively. | |
| Then add a method that nicely displays a summary of the person’s info, including the age, occupation, and mood. | |
| =end | |
| class School | |
| attr_reader :school_name, :instructor | |
| attr_accessor :students, :staff | |
| def initialize | |
| @school_name = 'ACLTC' | |
| @instructor = 'Jay Wengrow' | |
| @students = [Person.new({age: 45, first_name: 'Troy', last_name: 'Leach', occupation: 'Software Development', mood: 'Very HAPPY!'})] | |
| @staff = [] | |
| end | |
| def run | |
| add_student( Person.new({age: 35, first_name: 'John', last_name: 'Doe', occupation: 'Full Stack', mood: 'Happy'}) ) | |
| add_staff( Employees.new({first_name: 'Kunal', last_name: 'Bhatt', position: 'Director of Capstones'}) ) | |
| add_staff( Employees.new({first_name: 'Trevor', last_name: 'Jones', position: 'Director of Operations'}) ) | |
| student_roster | |
| list_of_employees | |
| end | |
| def add_student(new_student) | |
| students << new_student | |
| end | |
| def add_staff(new_employee) | |
| staff << new_employee | |
| end | |
| def student_roster | |
| puts <<-STRING | |
| School Name => #{school_name} | |
| instructor => #{instructor} | |
| = = = = = = = = = = = = = = = = = = | |
| #{school_name} Students: | |
| ----------------------------------- | |
| Name: #{students[0].last_name}, #{students[0].first_name} | |
| Age: #{students[0].age} | |
| Occupation: #{students[0].occupation} | |
| Students Mood: #{students[0].mood} | |
| STRING | |
| end | |
| def list_of_employees | |
| puts <<-STRING | |
| #{school_name} Staff: | |
| ----------------------------------- | |
| Name: #{staff[0].last_name}, #{staff[0].first_name} | |
| Position: #{staff[0].position} | |
| Name: #{staff[1].last_name}, #{staff[1].first_name} | |
| Position: #{staff[1].position} | |
| STRING | |
| end | |
| end | |
| class Person | |
| attr_accessor :age, :occupation, :mood | |
| attr_reader :first_name, :last_name # i guess the name could change too! | |
| def initialize(args = {}) | |
| @age = args[:age] | |
| @first_name = args[:first_name] | |
| @last_name = args[:last_name] | |
| @occupation = args[:occupation] | |
| @mood = args[:mood] | |
| end | |
| end | |
| class Employees | |
| attr_reader :first_name, :last_name, :position | |
| def initialize(args = {}) | |
| @first_name = args[:first_name] | |
| @last_name = args[:last_name] | |
| @position = args[:position] | |
| end | |
| end | |
| School.new.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow, you work fast! Take a break!