怎么用java定义一个员工类
答案:3 悬赏:60
解决时间 2021-02-18 12:52
- 提问者网友:原来太熟悉了会陌生
- 2021-02-17 18:25
怎么用java定义一个员工类
最佳答案
- 二级知识专家网友:神也偏爱
- 2021-02-17 18:51
写给你了
public class Employee {
public int workYear;
public double salary;
public double comsalary(){
return 50*workYear+salary;
}
}
package test1;
public class Manager extends Employee{
private double bonus;
public double comsalary(){
return 50*workYear+salary+bonus;
}
}
package test2;
public class Circle {
public double r;
public double area(){
return 3.14*r*r;
}
}
package test2;
public class Cylindar extends Circle{
public Cylindar(double r, double h) {
this.r=r;
this.h = h;
}
private double h;
public double getH() {
return h;
}
}
package test3;
public class Person {
private String name;
private int age;
private String sex;
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getSex() {
return sex;
}
public Person(String name, int age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
}
package test3;
public class Student extends Person{
public Student(String name, int age, String sex, String number) {
super(name, age, sex);
this.number = number;
}
private String number;
public String getNumber() {
return number;
}
}
public class Employee {
public int workYear;
public double salary;
public double comsalary(){
return 50*workYear+salary;
}
}
package test1;
public class Manager extends Employee{
private double bonus;
public double comsalary(){
return 50*workYear+salary+bonus;
}
}
package test2;
public class Circle {
public double r;
public double area(){
return 3.14*r*r;
}
}
package test2;
public class Cylindar extends Circle{
public Cylindar(double r, double h) {
this.r=r;
this.h = h;
}
private double h;
public double getH() {
return h;
}
}
package test3;
public class Person {
private String name;
private int age;
private String sex;
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getSex() {
return sex;
}
public Person(String name, int age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
}
package test3;
public class Student extends Person{
public Student(String name, int age, String sex, String number) {
super(name, age, sex);
this.number = number;
}
private String number;
public String getNumber() {
return number;
}
}
全部回答
- 1楼网友:想偏头吻你
- 2021-02-17 20:16
牛人啊还没下课吧 呵呵383808552
- 2楼网友:患得患失的劫
- 2021-02-17 20:08
我简单写一下你参考
public class Employee{
//定义属性
private int seniority = 0 ;//工龄
private double pay = 0.0;//工资
//属性公开方法
public int getSeniority(){
return this.seniority;
}
public double getPay(){
return this.pay;
}
public void setSeniority(int seniority){
this.seniority = seniority;
}
public void setPay(double pay){
this.pay = pay;
}
//计算工资的方法
public double comSalary(){
return this.seniority * 50 + pay;
}
}
祝你好运!
public class Employee{
//定义属性
private int seniority = 0 ;//工龄
private double pay = 0.0;//工资
//属性公开方法
public int getSeniority(){
return this.seniority;
}
public double getPay(){
return this.pay;
}
public void setSeniority(int seniority){
this.seniority = seniority;
}
public void setPay(double pay){
this.pay = pay;
}
//计算工资的方法
public double comSalary(){
return this.seniority * 50 + pay;
}
}
祝你好运!
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯