[java]代码库
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int m = scan.nextInt();
Manager r = new Manager(m);
System.out.println(r.getSalary());
m = scan.nextInt();
int b = scan.nextInt();
Salesman c = new Salesman (m,b);
System.out.println(c.getSalary());
int d = scan.nextInt();
m = scan.nextInt();
Worker w = new Worker(d,m);
System.out.print(w.getSalary());
scan.close();
}
}
abstract class Employee
{
public abstract int getSalary();
}
class Manager extends Employee
{
private int monthmoney;
public Manager(int m)
{
monthmoney = m;
}
public int getSalary()
{
return monthmoney;
}
}
class Salesman extends Employee
{
private int mmoney;
private int bonus;
public Salesman(int m, int b)
{
mmoney = m;
bonus = b;
}
public int getSalary()
{
return mmoney + bonus;
}
}
class Worker extends Employee
{
private int day;
private int daymoney;
public Worker (int d, int m)
{
day = d;
daymoney = m;
}
public int getSalary()
{
return day*daymoney;
}
}