Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class LabClass{
- private String instructor;
- private String room;
- private String timeAndDate;
- private int classCapacity;
- private ArrayList<Student>classList;
- public LabClass(int newClassCapacity){
- classCapacity = newClassCapacity;
- classList = new ArrayList<Student>();
- }
- public String getInstructor(){
- return instructor;
- }
- public String getRoom(){
- return room;
- }
- public String getTimeAndDate(){
- return timeAndDate;
- }
- public void setInstructor(String newInstructor){
- instructor = newInstructor;
- }
- public void setRoom(String newRoom){
- room = newRoom;
- }
- public void setTimeAndDate(String newTimeAndDate){
- timeAndDate = newTimeAndDate;
- }
- public int getSize(){
- return classList.size();
- }
- public void addStudent(Student item)
- {
- if(classList.size()<classCapacity){
- classList.add(item);
- }
- else{
- System.out.println("full capacity of class");
- }
- }
- public Student getSearchName(String searchName){
- String itemName;
- Student foundItem = null;
- int index =0;
- boolean found = false;
- while(index<classList.size() && !found){
- itemName=classList.get(index).getName();
- if(itemName.equals(searchName)){
- found = true;
- foundItem = classList.get(index);
- }
- else{
- index++;
- }
- }
- return foundItem;
- }
- public Student getSearchId(String searchId){
- String itemId;
- Student foundItem = null;
- int index =0;
- boolean found = false;
- while(index<classList.size() && !found){
- itemId=classList.get(index).getStudentID();
- if(itemId.equals(searchId)){
- found = true;
- foundItem = classList.get(index);
- }
- else{
- index++;
- }
- }
- return foundItem;
- }
- public void printClassListV2(){
- Iterator itr = classList.iterator();
- while(itr.hasNext()) {
- Object element = itr.next();
- System.out.print(element + " ");
- }
- System.out.println(print());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement