源码分析
Course.java
1 package com.ftl.many2many; 2 3 import java.util.*; 4 5 public class Course 6 { 7 private int credit; 8 private String name; 9 private List<Student> allStudent; 10 public int getCredit() 11 { 12 return credit; 13 } 14 public void setCredit(int credit) 15 { 16 this.credit = credit; 17 } 18 public String getName() 19 { 20 return name; 21 } 22 public void setName(String name) 23 { 24 this.name = name; 25 } 26 public List<Student> getAllStudent() 27 { 28 return allStudent; 29 } 30 public void setAllStudent(List<Student> allStudent) 31 { 32 this.allStudent = allStudent; 33 } 34 public Course() 35 { 36 this.allStudent = new ArrayList<Student>(); 37 } 38 public Course(String name, int credit) 39 { 40 this(); 41 this.setCredit(credit); 42 this.setName(name); 43 } 44 45 public String toString() 46 { 47 return "课程名称:" + this.name + "\t课程学分:" + this.credit; 48 } 49 }