S.A. Java Execute the class that has the first parameter name. Step-0 1 / 49
Nov 01, 2014
S.A. �
Java�
Execute the class that has the first parameter name.�
Step-0 1 / 49
S.A. �
Manager�Represent a manager�
Execute ・instantiate(new) Singer � with the data “name =� Michael height = 5.5” � ・command him to sing � ・command him to dance �
Step-0
Singer: michael
2 / 49
Note: This class can be executed without instantiate.
S.A. �
Singer�Singer Role�
Manage “name”�Manage “height”�sing � ・Display “(name) is singing.”�
dance � ・Display “(name) is dancing.��
Step-0
name
height
3 / 49
S.A. �
1:Singer�Singer Role�
Manage “name”�Manage “height”�sing � ・Display “(name) is singing.”�
dance � ・Display “(name) is dancing.��
Step-0
name
height
4 / 49
S.A. �
Screen �
Step-0,1,2 5 / 49
S.A. �
Java�
Execute the class that has the first parameter name and pass the other parameters.
If you’ll get an Runtime Exception,
catch it and show the message of it.
Step-1 Step-1,2 6 / 49
S.A. �
President�Represent a president�
Execute � ・instantiate(new) Employee � Factory �
・Get an Employee from � EmployeeFactory with the � second parameter.�
・Command Employee to � standup�
Step-1 Step-1
Note: This class can be executed without instantiate.
Employee factory : factory
Employee : employee
7 / 49
S.A. �
EmployeeFactory�Role: instantiate Employees�
Return an Employee
・If you get “new”, instantiate� (new) BrandNewEmployee and � return it.��
・If you get “mid”, � instantiate (new) � MidLevelEmployee and � return it.�
・If you get “exp”,� instantiate (new) � ExperiencedEmployee and � return it.�
If there is no proper Employee, set “No such a title employee.” to RuntimeException and throw it.�
Step-1,2 8 / 49
S.A. �
1:EmployeeFactory�Role: instantiate Employees�
If there is no proper Employee, set “No such title employee.” to RuntimeException and throw it.�
Step-1,2 9 / 49
Return an Employee
・If you get “new”, instantiate� (new) BrandNewEmployee and � return it.�
・If you get “mid”, � instantiate (new) � MidLevelEmployee and � return it.�
・If you get “exp”,� instantiate (new) � ExperiencedEmployee and � return it. �
S.A. �
Employee�Represent an Employee�
standup�
Step-1 10 / 49
S.A. �
BrandNewEmployee(Employee)�
Represent a brand new Employee�standup� ・display “A brand new � employee normally stands � up!” �
Step-1 11 / 49
S.A. �
MidLevelEmployee(Employee)�
Represent a mid-level Employee�standup� ・display “A mid-level � employee quickly � stands up!” �
Step-1 12 / 49
S.A. �
ExperiencedEmployee(Employee)�
Represent an experienced Employee�standup� ・display “A experienced� employee slowly stands up!” �
Step-1 13 / 49
S.A. �
2:BrandNewEmployee(Employee)�
Represent a brand new Employee�standup� ・display “A brand new � employee normally � stands up!” �
Step-1 14 / 49
S.A. �
3:MidLevelEmployee(Employee)�
Represent a mid-level Employee�standup� ・display “A mid-level� employee quickly � stands up!” �
Step-1 15 / 49
S.A. �
4:ExperiencedEmployee(Employee)�
Represent a Manager Employee�
standup� ・display “A experienced� employee slowly stands up!” �
Step-1 16 / 49
S.A. �
RuntimeException(Exception)�Represent Runtime Exception�
Step-2
Manage “error message” �
17 / 49
Error message
S.A. �
President�Represent a president�
Execute � ・instantiate(new) Employee � Factory. �
・Get an Employee from � EmployeeFactory with the � second parameter.�
・Command Employee to � standup.�
・Pass Employee the third � parameter as a base salary.�
・ask(get) salary from Employee �
・Display “Employee’s salary is � (salary) yen.”�
Step-2
Note: This class can be executed without instantiate.
Employee factory : factory
Employee : employee
18 / 49
S.A. �
Employee�Represent an Employee�
standup
manage “baseSalary” getSalary�
Step-1 19 / 49
base salary
S.A. �
BrandNewEmployee(Employee)�
Represent a brand new Employee�standup� ・display “A brand new � employee normally � stands up!” �
Step-1 20 / 49
getSalary ・return baseSalary as salary �
S.A. �
MidLevelEmployee(Employee)�
Represent a mid-level Employee�standup� ・display “A mid-level � employee quickly � stands up!” �
Step-1 21 / 49
getSalary ・return baseSalary x 2 + 1� as salary �
S.A. �
ExperiencedEmployee(Employee)�
Represent an experienced Employee�standup� ・display “an experienced � employee quickly stands up!” �
Step-1 22 / 49
getSalary ・return baseSalary x 3� as salary �
S.A. �
2:BrandNewEmployee(Employee)�
Represent a brand new Employee�standup� ・display “A brand new � employee normally � stands up!” �
Step-1 23 / 49
getSalary ・return baseSalary as salary �
base salary Manage “baseSalary”�
S.A. �
3:MidLevelEmployee(Employee)�
Represent a mid-level Employee�standup� ・display “A mid-level � employee quickly � stands up!” �
Step-1 24 / 49
getSalary ・return baseSalary x 2 + 1� as salary �
base salary Manage “baseSalary”�
S.A. �
4:ExperiencedEmployee(Employee)�
Represent an experienced Employee�standup� ・display “an experienced � employee quickly stands up!” �
Step-1 25 / 49
getSalary ・return baseSalary x 3� as salary �
base salary Manage “baseSalary”�