⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 labclass.java

📁 现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为project的文件里.安装好后用bluej打开peoject的例子,可以进行你想要的任何变化.同时可以了解大量的源码
💻 JAVA
字号:
import java.util.*;/** * The LabClass class represents an enrolment list for one lab class. It stores * the time, room and participants of the lab, as well as the instructor's name. *  * @author Michael Kolling and David Barnes * @version 2006.03.30 */public class LabClass{    private String instructor;    private String room;    private String timeAndDay;    private List<Student> students;    private int capacity;        /**     * Create a LabClass with a maximum number of enrolments. All other details     * are set to default values.     */    public LabClass(int maxNumberOfStudents)    {        instructor = "unknown";        room = "unknown";        timeAndDay = "unknown";        students = new ArrayList<Student>();        capacity = maxNumberOfStudents;    }    /**     * Add a student to this LabClass.     */    public void enrollStudent(Student newStudent)    {        if(students.size() == capacity) {            System.out.println("The class is full, you cannot enrol.");        }        else {            students.add(newStudent);        }    }        /**     * Return the number of students currently enrolled in this LabClass.     */    public int numberOfStudents()    {        return students.size();    }        /**     * Set the room number for this LabClass.     */    public void setRoom(String roomNumber)    {        room = roomNumber;    }        /**     * Set the time for this LabClass. The parameter should define the day     * and the time of day, such as "Friday, 10am".     */    public void setTime(String timeAndDayString)    {        timeAndDay = timeAndDayString;    }        /**     * Set the name of the instructor for this LabClass.     */    public void setInstructor(String instructorName)    {        instructor = instructorName;    }        /**     * Print out a class list with other LabClass details to the standard     * terminal.     */    public void printList()    {        System.out.println("Lab class " + timeAndDay);        System.out.println("Instructor: " + instructor + "   room: " + room);        System.out.println("Class list:");        for(Student student : students) {            student.print();        }        System.out.println("Number of students: " + numberOfStudents());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -