写出该程序运行的结果。
6.
package day14;
public class Demo14_3 {
public static void main(String[] args) {
Student stu=new Student("张三",23,"江苏","214000","1381402222");
System.out.println(stu.getName());
System.out.println(stu.getAge());
System.out.println(stu.getAdress());
System.out.println(stu.getZipCode());
System.out.println(stu.getMobile());
stu.getPostAddress();
}
}
class Student{
private String name;
private int age;
private String adress;
private String zipCode;
private String mobile;
public Student(String name,int age,String adress,String zipCode,String mobile){
this.name=name;
this.age=age;
this.adress=adress;
this.zipCode=zipCode;
this.mobile=mobile;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAdress() {
return adress;
}
public void setAdress(String adress) {
this.adress = adress;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public void getPostAddress(){
System.out.println(adress+" "+zipCode);
}
}
class Account{
private int id;
private double balance;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getPassword() {
return null;
}
public void setPassword(String password) {
if(password.length()!=6){
return;
}
this.password = password;
}
}
class SaveAccount extends Account{
private double interestRate;
public double getInterestRate() {
return interestRate;
}
public void setInterestRate(double interestRate) {
if(interestRate>0 && interestRate<10/100){
this.interestRate = interestRate;
}
}
}
class CreditAccount extends Account{
private double creditLine;
}
class Animal {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void eat(){
System.out.println(name+"吃東西");
}
public void call(){
System.out.println(name+"在叫...");
}
}
class Dog extends Animal{
@Override
public void eat() {
System.out.println(super.getName()+"在吃東西");
}
@Override
public void call() {
System.out.println(super.getName()+"在叫....");
}
}
class Cat extends Animal{
@Override
public void eat() {
System.out.println(super.getName()+"在吃東西");
}
@Override
public void call() {
System.out.println(super.getName()+"在叫....");
}
}
public class TestAnimal{
public static void main(String[] args) {
Animal a1 = new Dog();
a1.setName("夠");
a1.eat();
a1.call();
System.out.println();
Animal a2 = new Dog();
a2.setName("貓");
a2.eat();
a2.call();
}
}
public class TestEmployee {
public static void main(String[] args) {
SalariedEmployee se = new SalariedEmployee();
se.setName("李易峰");
se.setSalary(3000);
se.setBirthMonth(2);
se.getSalary(2);
HourlyEmployee he = new HourlyEmployee();
he.setName("张子明");
he.setHourSalary(25);
he.setHours(180);
he.getSalary();
SalesEmployee sae = new SalesEmployee();
sae.setName("林肯");
sae.setMonthsales(300000);
sae.setRoyalRate(0.003);
sae.getSalary();
BasePlusSalesEmployee bse = new BasePlusSalesEmployee();
bse.setName("阳光");
bse.setBaseSalary(1500);
bse.setMonthsales(200000);
bse.setRoyalRate(0.002);
bse.getSalary();
}
}
class Employee {
String name;
int birthMonth;
double salary;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBirthMonth() {
return birthMonth;
}
public void setBirthMonth(int birthMonth) {
this.birthMonth = birthMonth;
}
public void setSalary(double salary) {
this.salary = salary;
}
public void getSalary(int month) {
if (birthMonth == month) {
System.out.println(name + "当月月薪" + (salary + 100));
}
}
}
class SalariedEmployee extends Employee {
}
class HourlyEmployee extends Employee {
double hourSalary;
double hours;
double salary;
public double getHourSalary() {
return hourSalary;
}
public void setHourSalary(double hourSalary) {
this.hourSalary = hourSalary;
}
public double getHours() {
return hours;
}
public void setHours(double hours) {
this.hours = hours;
}
public void setSalary(double salary) {
this.salary = salary;
}
public void getSalary() {
if (hours > 160) {
System.out.println(name + "月薪为" + (hourSalary * 160 + ((hours - 160) * hourSalary * 1.5)));
} else {
System.out.println(name + "月薪为" + hourSalary * hours);
}
}
}
class SalesEmployee extends Employee {
double monthsales;
double royalRate;
public double getMonthsales() {
return monthsales;
}
public void setMonthsales(double monthsales) {
this.monthsales = monthsales;
}
public double getRoyalRate() {
return royalRate;
}
public void setRoyalRate(double royalRate) {
this.royalRate = royalRate;
}
public void setSalary(double salary) {
this.salary = salary;
}
public void getSalary() {
System.out.println(name + "月薪为" + monthsales * royalRate);
}
}
class BasePlusSalesEmployee extends SalesEmployee {
double baseSalary;
public double getBaseSalary() {
return baseSalary;
}
public void setBaseSalary(double baseSalary) {
this.baseSalary = baseSalary;
}
public void getSalary() {
System.out.println(name + "月薪为" + baseSalary + monthsales * royalRate);
}
}