java person类

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);
		
				

	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值