Australian Business Forum  

Go Back   Australian Business Forum > Wholesale Business Discussion > Payment and Shipping Discussion

Payment and Shipping Discussion Discuss payment services and shipping methods in here. Do you want an opinion on a payment method? Confused as to how a payment method works? Need advice with organising shipping? Get help and advice in here.


Reply
 
LinkBack Thread Tools
Old 28-04-08   #1
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
SonaMunda is on a distinguished road
Default Any Idea (JAVA)?

Consider the Employee class and two of its derived classes: HourlyEmployee and SalariedEmployee. Assume that any employee has an ID and a name. Assume that each salaried employee has a yearly salary. Assume that each hourly employee has an hourly rate and the number of hours he has worked this month. Write a program that implements these three classes. Utilizing "polymorphism", include the following method that compares employees to see if they get the same payment this month: public boolean samePay(Employee other) { return(this.getPay() == other.getPay()); } Where getPay() of salaried employees is calculated as (the yearly salary/12), and getPay() of hourly employees is calculated as (the hourly rate * number of hours).Provide two versions of the program where the Employee class is concrete in the first version, and it is Abstract in the second version.Note that a salaried employee can be compared not only to a salaried one but also to an hourly one as well, and vice versa.This is what I got so far: Thank you for the help in advancepublic class Employee { public double getPayroll(){return 0.0;}}public class SalariedEmployee extends Employee{private double m_Salary;public SalariedEmployee( double Salary ){m_Salary = Salary;} @Overridepublic double getPayroll(){return m_Salary / 12;}}public class HourlyEmployee extends Employee{private double m_HourlyRate;private double m_HoursWorked;public HourlyEmployee (int ID, Name);public HourlyEmployee ( double HourlyRate ){m_HourlyRate = HourlyRate;}public double HoursWorked (double HoursWorked){m_HoursWorked = HoursWorked; } @Overridepublic double getPayroll(){return m_HoursWorked * m_HourlyRate;}}
SonaMunda is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Sponsored Links
Old 29-04-08   #2
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ayesha8692 is on a distinguished road
Default Any Idea (JAVA)?

you can get all java type help fromhttp://codingjava.info/
ayesha8692 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 29-04-08   #3
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
blessed_thang1154 is on a distinguished road
Default Any Idea (JAVA)?

public abstract class Employee { private String id; private double hourlyRate; private float numHours; public Employee( String i, double rate ){ id = i; hourlyRate = rate; } private float getHours() { return numHours; } protected double getRate() { return hourlyRate; } public double getPayroll() { return numHours * hourlyRate; } protected boolean samePay( Employee other ) { return (this.getPayroll() == other.getPayroll() ); }}==============public class Salaried extends Employee { public Salaried(String id, double salary) { super(id, salary); } public double getPayroll() { return getRate() / 12; }}====================public class Hourly extends Employee { public Hourly( String id, double rate ) { super(id, rate ); }}==================public class Payroll { static ArrayList<Employee> employees; // not used, but polymorphism public static void main( String[] args ) { employees = new ArrayList<Employee>(); Hourly JebBush = new Hourly("JB01",9.09); Salaried DubyaBush = new Salaried("W01",6.65); employees.add(JebBush); employees.add(DubyaBush); System.out.println(JebBush.samePay(DubyaBush)); }}You could enumerate ArrayList. Then, if need be,if( employee.get(i) instanceof Salaried )System.out.println("Well, why didn't you say so.");
blessed_thang1154 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Reply

Tags
idea, java

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +11. The time now is 04:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0