public class EmployeeClass{
private String name; // 名字
private int id; //公司编号
private double salary; //薪水
private String department;// 部门
public EmployeeClass(){}
public EmployeeClass(String name,int id,double salary,String department){
this.name = name;
this.id = id;
this.salary = salary;
this.department = department;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Override
public String toString() {
return "EmployeeClass [name=" + name + ", id=" + id + ", salary="
+ salary + ", department=" + department + "]";
}
}
public class ManagerClass extends EmployeeClass{
private double specialsalary;
public ManagerClass(){super();}
public ManagerClass(String name,int id,double salary,String department,double specialsalary){
super(name,id,salary,department);
this.specialsalary = specialsalary;
}
public double getSpecialsalary() {
return specialsalary;
}
public void setSpecialsalary(double specialsalary) {
this.specialsalary = specialsalary;
}
@Override
public String toString() {
return super.toString() + "\nspecialsal:" +specialsalary;
}
}
public void setInfo(String name,int id,double salary,String department){
this.name = new String(name);
this.id = id;
this.salary = salary;
this.department = new String(department);
}
public void setInfo(String name,int id,double salary,String department,double specialsalary){
super(name,id,salary,department);
this.specialsalary = specialsalary;
}
public boolean euqals(Object obj){
return (this == obj);
}
public class ComplexNumber {
private double re;
private double im;
public ComplexNumber(){re = 0.0;im = 0.0;}
public ComplexNumber(double re,double im){
this.re = re;
this.im = im;
}
public double getRe() {
return re;
}
public void setRe(double re) {
this.re = re;
}
public double getIm() {
return im;
}
public void setIm(double im) {
this.im = im;
}
public boolean equals(Object otherObject){
if(this == otherObject) return true;
if(otherObject == null) return false;
if(getClass() != otherObject.getClass()) return false;
ComplexNumber other = (ComplexNumber)otherObject;
if((re == other.re) && (im == other.im)) return true;
else return false;
}
public String toString(){
String str = "";
if(re != 0) str += re;
if(im == 0) return str;
if( im < 0 ) str += im +"i";
else str += " + " + im +"i";
return str;
}
public static void main(String[] args) {
ComplexNumber c1,c2;
c1 = new ComplexNumber(2,3);
c2 = new ComplexNumber(2,-3.4);
if(c1.equals(c2)){
System.out.println("("+c1+") == ( " + c2 +")" );
}
else{
System.out.println("("+c1+") <> ( " + c2 +")" );
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有