Package day09;
/**
* Employee Example:
* Requirements: The company's programmers have name, work number, salary, job content.
* Project Manager In addition to name, work number, salary, bonus, job content.
* Model data for the given requirements.
*
Analysis
* In this area of problem, first find out the object of design.
* by refining the method.
Programmers
* Attributes: Name, work number, salary
* Behavior: Work
Manager
* Attributes: Name, work number, salary, bonus.
* Behavior: Work
*
* There is no direct inheritance between programmers and managers, but programmers and managers have common content. can be extracted. Because they are employees of the company, they can extract the programmer and the manager and build the system.
*/
Describe employee
Abstract class employee{
private String name;
Private String ID;
private double pay;
Employee (String name,string id,double pay) {
THIS.name = name;
This.id = ID;
This.pay = pay;
}
public abstract void work ();
}
Describe the programmer
Class Programmer extends employee{
Programmer (String name,string id,double pay) {
Super (Name,id,pay);
}
public void work () {
SYSTEM.OUT.PRINTLN ("code ...");
}
}
Description Manager
Class Manager extends employee{
private int bouns;
Manager (String name,string id,double pay,int bounus) {
Super (Name,id,pay);
This.bouns = Bouns;
}
public void work () {
System.out.println ("manager");
}
}
public class Abstracttest {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
}
}
Class person{
private String name;
private int age;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.