设计一个课程和教材管理系统-小作业

//课程类

public class course {

	int id;
	String name;
	int studyHour;
	String teacherName;
	String bookName;

	//无参构造方法
	public course() {}
	//有参构造方法
	public course(int i, String n, int s, String t, String b) {
		this.id = i;
		this.name = n;
		this.studyHour = s;
		this.teacherName = t;
		this.bookName = b;
	}
	//更改器
	public void setCourse(int i, String n, int s, String t, String b) {
		id = i;
		name = n;
		studyHour = s;
		teacherName = t;
		bookName = b;

	}
	//获取器
	public String toString(){
		return "课程编号:" +id + '\t' + "课程名称:" +  name + '\t' + "所需课时:" + studyHour +"课时" + '\t' + "任课教师:" + teacherName + '\t' + "课程书籍:" + bookName;
	}

}

//书籍类

public class Tbook {
    
	int bookId;
	String bookName;
	String author;
	double price;
	
	public Tbook(){}
	public Tbook(int bookId,String bookName,String author,double price){
		this.bookId = bookId;
		this.bookName = bookName;
		this.author = author;
		this.price = price;
	}
	
	public void setTook(int bookId,String bookName,String author,double price){
		this.bookId = bookId;
		this.bookName = bookName;
		this.author = author;
		this.price = price;
	}
	public String toString(){
		return "书籍编号: " + bookId + '\t' +"书籍名称:" + bookName +'\t' + "书籍作者:" + author +'\t'+"书籍价格:"  + price;
	}
}


//测试类

public class Test {
	public static void main(String[] args) {
		
		course p = new course();
		p.setCourse(001,"世界与中国", 5, "肖晓明", "中国游记");
		
		Tbook t = new Tbook();
		t.setTook(001, "中国游记", "肖晓明", 35.8);
		
		System.out.println(p.toString());
		System.out.println(t.toString());
		

	}
}



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值