Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this Class is for java homework name: Lesson012_28_08_19_Task2
- public class Employee {
- protected String name;
- protected double salary;
- private static int sysId = 1000;
- // builders:
- public Employee(String name, int sysId, double salary) {
- System.out.println("Employee() full constructor");
- this.name = name;
- this.sysId = sysId;
- this.salary = salary;
- }
- public Employee() {
- // random salary between 6,000 and 9,000.
- this("employee No" + (sysId-1000), sysId, ((int)(Math.random()*6)*500) + 6000);
- System.out.println("Employee() empty constructor");
- sysId += 1; // increase count of employees
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- public double calcBonus(double bonus) {
- return bonus;
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- public void updateSalary (double bonus) {
- this.salary = salary + calcBonus(bonus);
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- @Override
- public String toString() {
- return "Employee{" +
- "name='" + name + '\'' +
- ", sysId=" + + sysId +
- ", salary=" + salary +
- '}';
- }
- }
- // ####################################################################################################
- // this Class is for java homework name: Lesson012_28_08_19_Task2
- public class Programmer extends Employee {
- // builders:
- public Programmer (String name, int sysId, int salary) {
- super(name, sysId, salary);
- }
- public Programmer () {
- super();
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- public double calcBonus() {
- return salary * 0.5f;
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- @Override
- public String toString() {
- return "Programmer type " + super.toString();
- }
- }
- // ####################################################################################################
- // this Class is for java homework name: Lesson012_28_08_19_Task2
- public class Secretary extends Employee {
- private int wordsPerMinute;
- // builders:
- public Secretary (String name, int sysId, int salary, int wordsPerMinute) {
- super(name, sysId, salary);
- this.wordsPerMinute = wordsPerMinute;
- }
- public Secretary () {
- super();
- this.wordsPerMinute = (int)(Math.random()*30);
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- public double calcBonus() {
- return calcBonus(500);
- }
- // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- @Override
- public String toString() {
- return "Secretary type " + super.toString() +
- "{wordsPerMinute=" + wordsPerMinute +
- '}';
- }
- }
Add Comment
Please, Sign In to add comment