
/*
 * Copyright 2015 Alistair Madden <phantommelon@gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Describes the people within the company, and methods to analyse them.
 * 
 * @author Alistair Madden <phantommelon@gmail.com> 
 * @version 1.0
 */

import java.util.ArrayList;

public class Company {
    
    private ArrayList<Person> associatedPersons;
    
    public Company() {
        associatedPersons = new ArrayList();
    }
    
    public void addPerson(Person person) {
        associatedPersons.add(person);
    }
    
    public void getInformation(String name) {
        
        for(Person person : associatedPersons) {
            
            if(person.getName().equals(name)) {
                
                System.out.println(person.getDescription());
            }
        }
    }
    
    public void listAllPeople() {
        for(Person person : associatedPersons) {
            System.out.println(person.getDescription());
        }
    }
}

class test {
    public static void main(String args[]) {
        Person person = new Employee("A", "B", "C", 20);
        System.out.println(person);
    }
}
@@ -803,16 +803,41 @@
 rayList;
+%0Aimport java.util.Arrays;
 %0A%0Apublic
@@ -1522,65 +1522,672 @@
   %7D%0A
-%7D%0A%0Aclass test %7B%0A    public static void main(String args%5B%5D
+    %0A    public void calculatePayment() %7B%0A        for(Person person : associatedPersons) %7B%0A            %0A            ArrayList%3CString%3E names = new ArrayList%3C%3E(Arrays.asList(person.getName().split(%22 %22)));%0A            %0A            String surname = names.get(names.size() - 1);%0A            %0A            ArrayList%3CString%3E firstNames = new ArrayList();%0A            %0A            for(String name : names) %7B%0A                if(!name.equals(surname)) %7B%0A                    firstNames.add(name);%0A                %7D%0A            %7D%0A            %0A            System.out.println(%22Surname: %22 + surname + %22%5Cn%22 + %22First Name(s):%22);%0A            %0A            for(String name : firstNames
 ) %7B%0A
@@ -2198,96 +2198,565 @@
     
+  
-Person person = new Employee(%22A%22, %22B%22, %22C%22, 20);%0A        System.out.println(person);%0A    %7D%0A%7D
+      System.out.print(%22 %22 + name);%0A            %7D%0A            %0A            if(!(person.getShare() == null)) %7B%0A                System.out.println(%22Dividend Due: %22 + person.getShare().getDividend());%0A            %7D%0A            %0A            if(person instanceof ContractedWorker) %7B%0A                ContractedWorker employee = (ContractedWorker) person;%0A                %0A                System.out.println(%22Payment Due: %22 + employee.getSalary().getAmount() +%0A                        employee.getSalary().getPaymentSchedule());%0A            %7D%0A        %7D%0A    %7D%0A    %0A%7D%0A

Add calculatePayment method to Company class