Cześć, czy da się zrobić tak żeby w obiekcie staff[1] = new Employee("user_2"); nie było parametru salary i w jego miejsce nic nie wyświetlono w wyniku? Docelowym wynikiem ma być:
name=user_1,salary=10500.0
name=user_2
import java.util.*;
public class test
{
public static void main(String[] args)
{
Employee[] staff = new Employee[4];
staff[0] = new Employee("user_1", 10000);
staff[1] = new Employee("user_2");
for (Employee e : staff)
e.raiseSalary(5);
for (Employee e : staff)
System.out.println("name=" + e.getName() + ",salary=" + e.getSalary();
class Employeee
{
private String name;
private double salary;
public Employeee(String n, double s)
{
name = n;
salary = s;
}
public String getName()
{
return name;
}
public double getSalary()
{
return salary;
}
public void raiseSalary(double byPercent)
{
double raise = salary * byPercent/100;
salary += raise;
}
}