0
該程序假設將員工添加到數組,然後爲每個員工/經理分配一個分配。取決於他們是經理/員工的分配是不同的數量,並且最終所有分配都被添加。構造函數java試圖做一個簡單的程序
我在哪裏試圖找出如何計算所有員工加入後的總數。
package pay;
import java.util.*;
public class manager
{
static double allocation =0;
public manager(String string, int i, String type) {
//
}
public static void main(String[] args)
{
// construct a Manager object
manager boss = new manager("Carl Cracker", 80000, "QA");
int total = 0;
Employee[] staff = new Employee[3];
// fill the staff array with Manager and Employee objects
// staff[0] = boss;
staff[1] = new Employee("Harry Hacker", 0,"Dev");
staff[2] = new Employee("Tommy Tester", 0,"QA");
// print out information about all Employee objects
int i;
for (i=0; i<3; i++)
{
total += allocation;
}
}
}
class Employee
{
public Employee(String string, int i, String string2) {
// TODO Auto-generated constructor stub
}
public double Employee(String n, int s, String type)
{
if (type.equals("Dev"))
allocation = 1000;
else if (type.equals("QA"))
allocation = 500;
else
allocation = 250;
return allocation;
}
private double getallocation()
{
return allocation;
}
private double allocation;
public String getName()
{
return name;
}
private String name;
}
class Manager extends Employee
{
public Manager(String string, int i, String string2) {
super(string, i, string2);
// TODO Auto-generated constructor stub
}
/*
n the employee's name
s the salary
*/
public double manager(String n, double s)
{
n= getName();
double getAllocation = 0;
s = getAllocation;
s=s+300;
return s;
}
}
而問題是什麼? ... – alfasin 2015-02-11 03:44:52
爲什麼你有一個'經理級**和**經理級?另外,爲什麼**? – 2015-02-11 03:48:04
@ElliottFrisch也許記得java區分大寫和小寫zz – ikh 2015-02-11 03:54:12