public class Book {
private long bookId;
private String BookName;
private String author;
private String publisher;
private int price;
public Book(){
}
public Book(long bookId,String BookName,String author,String publisher,int price){
this.author=author;
this.bookId=bookId;
this.BookName=BookName;
this.price=price;
this.publisher=publisher;
}
public void show(){
System.out.println("书籍编号"+bookId);
System.out.println("书籍名"+BookName);
System.out.println("书籍作者"+author);
System.out.println("书籍价格"+price);
System.out.println("出版单位"+publisher);
}
public long getBookId() {
return bookId;
}
public void setBookId(long bookId) {
this.bookId = bookId;
}
public String getBookName() {
return BookName;
}
public void setBookName(String bookName) {
BookName = bookName;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
public class Vehicle {
private String vehId;
private String vehUse;
private String author;
private int oil;
private String color;
private int price;
public Vehicle (){
}
public Vehicle(String vehId,String vehUse,String author,int oil,String color,int price){
this.author=author;
this.color=color;
this.oil=oil;
this.price=price;
this.vehId=vehId;
this.vehUse=vehUse;
}
public void show(){
System.out.println("车辆ID:"+vehId);
System.out.println("用途:"+vehUse);
System.out.println("性能:"+author);
System.out.println("油耗:"+oil);
System.out.println("价格:"+price);
System.out.println("颜色:"+color);
}
public void star(){
System.out.println("车辆启动!");
}
public void stop(){
System.out.println("车辆停止!");
}
public String getVehId() {
return vehId;
}
public void setVehId(String vehId) {
this.vehId = vehId;
}
public String getVehUse() {
return vehUse;
}
public void setVehUse(String vehUse) {
this.vehUse = vehUse;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getOil() {
return oil;
}
public void setOil(int oil) {
this.oil = oil;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
public class Person {
private String idCard;
private String name;
private String sex;
private int age;
public Person(){
}
public Person(String idCard,String name,String sex,int age){
this.age=age;
this.idCard=idCard;
this.name=name;
this.sex=sex;
}
public void sleep(){
System.out.println("ZZZZ!");
}
public void eat(String food){
System.out.println("今天吃了"+food);
}
public String listenAndSpeak(String word){
return word;
}
public void buy(Book book){
book.show();
}
public void buy(Vehicle vehicle){
vehicle.show();
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
public class TestVehicle {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Person person=new Person("19952522552631","高估尊","男",20);
person.sleep();
person.eat("1000个馒头");
Book book=new Book(10001,"高估尊是怎么炼成的","烟台大学出版社","高估尊",0);
person.buy(book);
Vehicle h=new Vehicle("悍马","运垃圾","很高",10,"大红",10000);
person.buy(h);
}
}