Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package studentmanagement;
- import java.util.ArrayList;
- import java.util.Scanner;
- import java.lang.String;
- public class StudentManagement {
- public static void main(String[] args) {
- // TODO code application logic here
- Student sv = new Student();
- sv.setName("Minh");
- sv.setID("123456");
- sv.setGroup("K61T");
- sv.setEmail("xxx@gmail.com");
- System.out.println("Name : "+ sv.getName());
- sv.getInfo();
- Student s1 = new Student();
- Student s2 = new Student();
- Student s3 = new Student();
- s1.setGroup("K59CLC");
- s2.setGroup("K59CLC");
- s3.setGroup("K59B");
- if(sameGroup(s1, s2) == true){
- System.out.println("True");
- }
- else System.out.println("False");
- if(sameGroup(s1, s3) == true){
- System.out.println("True");
- }
- else System.out.println("False");
- // Student[] svlist = new Student[100];
- //
- // svlist[0].setName("Anh");
- // svlist[0].setID("123");
- // svlist[1].setName("Binh");
- // svlist[1].setID("1111");
- //
- // for(Student index : svlist){
- // System.out.println("Name : " + index.getName());
- // System.out.println("ID : " +index.getID());
- // }
- ArrayList<Student> listStudent = new ArrayList<Student>();
- Student svlist1 = new Student();
- svlist1.setName("Anh");
- svlist1.setID("123");
- svlist1.setGroup("K61T");
- svlist1.setEmail("qqq@gmail.com");
- Student svlist2 = new Student();
- svlist2.setName("Binh");
- svlist2.setID("567");
- svlist2.setGroup("K61T");
- svlist2.setEmail("ppp@gmail.com");
- listStudent.add(0,svlist1);
- listStudent.add(1,svlist2);
- for(Student index : listStudent){
- System.out.println("Name " + index.getName());
- System.out.println("ID : " + index.getID());
- System.out.println("Group : " + index.getGroup());
- System.out.println("Email : " + index.getEmail());
- }
- studentByGroup(listStudent);
- removeStudent(listStudent);
- }
- public static boolean sameGroup(Student s1, Student s2){
- boolean isSameGroup = false;
- if(s1.getGroup() == s2.getGroup()){
- isSameGroup = true;
- }
- return isSameGroup;
- }
- public static void studentByGroup(ArrayList<Student> arrStudent){
- Scanner input = new Scanner(System.in);
- boolean isSameGroup = false;
- String group = new String();
- System.out.println("Enter the group : ");
- group = input.next();
- System.out.println("List of student in the group " + group + " : ");
- for(Student index : arrStudent)
- {
- if(index.getGroup().equals(group))
- {
- System.out.println(index.getName());
- }
- }
- }
- public static void removeStudent(ArrayList<Student> arrStudent){
- Scanner input = new Scanner(System.in);
- String inputID = new String();
- System.out.println("Enter the student's id : ");
- inputID = input.next();
- for(Student indexStudent : arrStudent){
- if(indexStudent.getID().equals(inputID)){
- arrStudent.remove(arrStudent.indexOf(indexStudent));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement