Results 1 to 9 of 9
  1. #1
    Anzo31 is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Post add igroup of tems to an ArrayList

    I want to Create an Employees class. It will contain 1 arraylist which holds Payable objects (Manager, HourlyWorker, all implement Payable). It will have a method to addEmployee, calculateWeeklyTotal, retrieve number of managers, hourly workers. and the toString method will print out the employee number and weekly pay for all employees. It will have a generateWeeklyPayReport method that returns a string with the entire report.
    Also the class Manager contain variable to hold paycode1, the salary and the ID
    and the class HourlyWorker contain variable to hold paycode2, hourly salary, and hours worked (for this class, employeees recieve fixed hourly wage for up to the first 40 hours they work and "time-and-a-half," i.e., 1.5 times their hourly wage, for overtime hours worked),
    payable interface has the methode public double calculateWeeklyPay();

    Please help me

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    please post what you have tried

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    Anzo31 is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default How to set the addEmployeees that take parameter String from both manager and HourlyW

    Java Code:
    public class Employees
    {
    private payable Manager;
    
    private payable HourlyWorker;
    
    
    private ArrayList<String>EmployeesBorad;
    
    private int paycode;
    
    public Employees() 
    {	
    	EmployeesBorad= new ArrayList<String>();
    	paycode = 0;
    	
    	Manager = null;
    	HourlyWorker = null;
    	
    }
    public void addEmployees (String Manager, String HourlyWorker)
    {
    	if paycode = 1;
    		
    	EmployeesBorad.add(Manager);
    
                if paycode = 2;
    
    	EmployeesBorad.add(HourlyWorker);
    	}
    
    ......
    }
    Last edited by Eranga; 11-14-2010 at 03:30 PM. Reason: code tags added

  5. #5
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    I am guessing Manager and HourlyWorker are classes? In which case they are hardly of type String? maybe one of there methods are of type String and that is what you need to pass to the addEmployee Method (Changing parameter information of course)
    Last edited by al_Marshy_1981; 11-14-2010 at 04:49 AM. Reason: 'e'

  6. #6
    Anzo31 is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    Here is the Manager Class which almost like the HourlyWorker class
    Java Code:
    public class Manager implements payable
    {
    private int paycode;
    private int ID;
    
    private double salary;
    
    
    public Manager(int id, double wage)
    { 
    
    ID = id;
    
    salary = wage; 
    paycode = 1;
    
    }
    
    public double calculateWeeklyPay()
    {
    return salary;
    
    }
    
    public String toString()
    {
    	String StringSalary = "";
    	StringSalary = salary ", " + ID;
    	
    	return StringSalary; 
    }
    
    }
    Last edited by Eranga; 11-14-2010 at 03:32 PM. Reason: code tags added

  7. #7
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Okay so in your opinion is Manager of type String?

  8. #8
    Anzo31 is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    ok let me make some corrections and submit it for you guys to take look on it. Please I am sorry I was at work and I just get home.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Anzo31 View Post
    ok let me make some corrections and submit it for you guys to take look on it. Please I am sorry I was at work and I just get home.
    When you are posting code segments next time please use code tags. Unformated codes may hard to read for others. If you don't know how to do it, check my forum signature. You can find the relevant link to the explanation. :)

Similar Threads

  1. Creating an ArrayList from an ArrayList
    By Klahking in forum New To Java
    Replies: 17
    Last Post: 09-09-2010, 04:34 PM
  2. Arraylist
    By gnarly hogie in forum New To Java
    Replies: 2
    Last Post: 12-11-2008, 02:59 AM
  3. Replies: 2
    Last Post: 04-21-2008, 12:43 PM
  4. ArrayList
    By kizilbas1 in forum New To Java
    Replies: 11
    Last Post: 12-05-2007, 08:30 PM
  5. New to arraylist
    By kleave in forum New To Java
    Replies: 2
    Last Post: 11-19-2007, 07:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •