Question
my work: public void addStudent(students st) { ///check if student is not in the list if (hasStudent(st) < 0) { studentList.add(st); } } public void
my work:
public void addStudent(students st) {
///check if student is not in the list
if (hasStudent(st) < 0) {
studentList.add(st);
}
}
public void WASTA(students st, int index) {
///check if student is not in the list
if (hasStudent(st) < 0) {
studentList.add(index, st);
}
}
public students removestudent(students st) {
if (studentList.remove(st)) {
return st;
} else {
return null;
}
}
//// print array
public void printList() {
for (students stu : studentList) {
System.out.println(stu);
}
}
}
Student class :
public class students {
private String name;
private String Id;
public students(String n, String r) {
this.name = n;
this.Id = r;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return Id;
}
public void setId(String Id) {
this.Id = Id;
}
// for checking if name and id are equal
public boolean equals(Object stx) {
students other = (students) stx;
if (!name.equals(other.name)) {
return false;
}
if (!Id.equals(other.Id)) {
return false;
}
return true;
}
public String toString() {
return "Name: " + name + ", ID: " + Id;
}
}
Main class:
public static void main(String[] args) {
course oop = new course("oop", "ITBP219");
course DS = new course("Data Structure", "ITBP319");
students st = new students("Zina", "9991");
oop.addStudent(st);
st = new students("Khawla", "8882");
oop.addStudent(st);
st = new students("Alia", "7773");
oop.addStudent(st);
st = new students("Hajar", "6664");
oop.addStudent(st);
st = new students("Bakhita", "5555");
oop.addStudent(st);
System.out.println("**First List**");
oop.printList();
///if we want to check and find a student
students findStudent = new students("Alia", "7773");
if (oop.hasStudent(findStudent) >= 0) {
System.out.println();
}
//
// System.out.println("**Second List**");
// students RMStudent = new students("Zina", "9991");
// oop.removestudent(RMStudent);
//
// oop.printList();
//
// System.out.println("**Third List**");
// st = new students("Bakhita", "5555");
// oop.WASTA(st, 0);
// oop.printList();
System.out.println("**Second List**");
}
}
For this assignment, do the following:
1- In the class, we have created Student Class, Course class and Main class. Inside of these classes, we have created various methods. Go to the Course class, and create a method inside the Course class that sort the students base on alphabet (2points). The method name should be SortStudentsName (1point)
2- Go to the Main class, and test the Sort method. So it sorts the students names (1Point)
3- Print the students list before and after the sorting (1Point)
4- Upload in blackboard the complete code for the 3 classes in single WORD file (1Point)
5- In the word file (add a print screen of the result) (1Point)
6- Remove the previous names and ID of the students, and add new students name and ID to the course of OOP, as follow (1Point):
Zina, 9991
Khawla, 8882
Alia, 7773
Hajar, 6664
Bakhita, 5555
NOTE : Email submission/Empty submission is not be acceptable.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started