Sup Java Com - Work
@Override public String getDetails() { return String.format("Manager[id=%d,name=%s,salary=%.2f,bonus=%.2f]", id, name, getSalary(), bonus); } } File: com/example/work/util/Formatter.java
@Override public double getSalary() { // use super.getSalary() to reference parent behavior return super.getSalary() + bonus; }
public class Main { public static void main(String[] args) { Employee dev = new Employee("Alice", 101, 70000); Manager mgr = new Manager("Bob", 201, 90000, 15000); sup java com work
package com.example.work.employee;
public class Formatter { public static String pretty(Employee e) { return e.getDetails(); } } File: com/example/work/Main.java @Override public String getDetails() { return String
package com.example.work;
public Manager(String name, int id, double baseSalary, double bonus) { super(name, id, baseSalary); // use of super to call parent constructor this.bonus = bonus; } Manager mgr = new Manager("Bob"
public class Employee { protected String name; protected int id; protected double baseSalary;