(A)
public class Address {
private String street;
public String city;
public String zipCode;
public void printAddress(){
System.out.println(this.street);
}
public void setStreet(String street){
this.street = street;
}
public String getStreet(){
return this.street;
}
}
(B)
public class Person {
public String firstName;
public String lastName;
public Address address;
@Override
public String toString() {
// TODO Auto-generated method stub
return firstName+lastName+address.getStreet();
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
(C)
import java.util.Date;
import java.util.Scanner;
public class Student extends Person {
private String identifiacationNumber;
private Date absentTime;
private double scoresMidtermExam=0;
private double scoresFinalExam=0;
public double getScoresMidtermExam() {
return scoresMidtermExam;
}
//设置期中考试的值,并且在0~50;
public void setScoresMidtermExam(double scoresMidtermExam) {
this.scoresMidtermExam = scoresMidtermExam;
while(this.scoresMidtermExam>50||this.scoresMidtermExam<0){
System.out.println("请输入一个0~50的其中考试成绩");
Scanner sc= new Scanner(System.in);
this.scoresMidtermExam =sc.nextDouble();
}
this.scoresMidtermExam = scoresMidtermExam;
}
public double getScoresFinalExam() {
return scoresFinalExam;
}
//设置期末考试的值,并且在0~50;
public void setScoresFinalExam(double scoresFinalExam) {
this.scoresFinalExam = scoresFinalExam;
while(this.scoresMidtermExam>50||this.scoresMidtermExam<0){
System.out.println("请输入一个0~50的期末考试成绩");
Scanner sc= new Scanner(System.in);
this.scoresFinalExam =sc.nextDouble();
}
}
//计算学生期中期末考试成绩的和
public double scoresAltogether(){
return this.scoresMidtermExam+this.scoresFinalExam ;
}
//判断学生成绩是否过60
public boolean pass(){
double sum = scoresAltogether();
if(sum>60)
return true;
else
return false;
}
}
一
class Address{
private string street;
public string city;
public string zipCode;
public void printAddress(){
println(this.street);
}
public void setStreet(String street){
this.street = street;
}
public string getStreet(){
return this.street;
}
二、
class Person{
private string firstName;
private string lastName;
private string address;
public string ToString (string firstName, string lastName,string address){
return (firstName + lastName + address);
}
}
路过高手都写完了!!!