diff --git a/1_GirlsCode_Student-Alumni-Networking-Platform/Alumni_Profile.java b/1_GirlsCode_Student-Alumni-Networking-Platform/Alumni_Profile.java new file mode 100644 index 0000000..9852931 --- /dev/null +++ b/1_GirlsCode_Student-Alumni-Networking-Platform/Alumni_Profile.java @@ -0,0 +1,1044 @@ +package alumni; + +import java.util.Scanner; + +import student.Student; + +//Alumni Node Class + +class Alumni_Node { + + Scanner sc = new Scanner(System.in); + + String fname; + + String lname; + + String email; + + int year; + + String branch; + + String description; + + String password; + + String question; + + int identity_no; + + Alumni_Node next; + + Alumni_Node(String fname, String lname, String email, int year, String branch, String description, String password, + + int identity_no, String question) { + + this.fname = fname; + + this.lname = lname; + + this.email = email; + + this.year = year; + + this.branch = branch; + + this.description = description; + + this.password = password; + + this.identity_no = identity_no; + + this.question = question; + + next = null; + + } + +} + +//Alumni Methods Class + +public class Alumni_Profile { + + boolean value; + + Scanner sc = new Scanner(System.in); + + private Alumni_Node head; + + public Alumni_Profile() { + + head = null; + + } + +//Alumni Sign Up + + public void signup() { + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t SIGN IN \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println("\n\n* This Application Is Applicable Only For Cummins Students *\n"); + + System.out.print("\n\nFIRST NAME : "); + + String fname = sc.next(); + + boolean value = onlyAlphabets(fname); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + fname = sc.next(); + + value = onlyAlphabets(fname); + + } + + System.out.print("\nLAST NAME : "); + + String lname = sc.next(); + + value = onlyAlphabets(lname); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + lname = sc.next(); + + value = onlyAlphabets(lname); + + } + + System.out.print("\nEMAIL : "); + + String email = sc.next(); + + sc.nextLine(); + + if (!email.contains("@cumminscollege.in")) { + + System.out.println("\n\nPLEASE ENTER A VALID EMAIL ID!"); + + return; + + } + + if (head == null) { + + head = temp; + + } + + else { + + Alumni_Node ptr = head; + + boolean emailexits = false; + + while (ptr != null) { + + if (email.equals(ptr.email)) { + + emailexits = true; + + break; + + } + + ptr = ptr.next; + + } + + if (emailexits) { + + System.out.println("\n\nYOU HAVE ALREADY SIGNED!!"); + + return; + + } + + } + + System.out.print("\nBRANCH : "); + + String branch = sc.nextLine(); + + value = onlyAlphabets(branch); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + branch = sc.nextLine(); + + value = onlyAlphabets(branch); + + } + + int year; + + try { + + System.out.print("\nYEAR OF PASSING : "); + + year = sc.nextInt(); + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + year = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.println("\n\nSecurity Question : "); + + System.out.println("\nWhat was your favorite food as a child?"); + + String question = sc.nextLine(); + + value = onlyAlphabets(question); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + question = sc.nextLine(); + + value = onlyAlphabets(question); + + } + + System.out.print("\nYOUR SPECIALIZATIONS : "); + + String specialization = sc.nextLine(); + + value = onlyAlphabets(specialization); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + specialization = sc.nextLine(); + + value = onlyAlphabets(specialization); + + } + + System.out.println( + + "\n\n* Your Password Must Contain 8 Characters, Atleast One Must be of Upper Case, Lower Case, Number and a Special Character *\n"); + + System.out.print("\nSET PASSWORD : "); + + String password = sc.nextLine(); + + boolean output = isPasswordValid(password); + + while (!output) { + + System.out.println("\n\nINVALID PASSWORD!. Please Try Again."); + + System.out.print("\n\nEnter A Password Again : "); + + password = sc.nextLine(); + + if (isPasswordValid(password)) { + + System.out.println("\n\n\nPassword Is Valid.\n"); + + output = true; + + } + + } + + System.out.print("\n\nCONFIRM PASSWORD : "); + + String re_password = sc.nextLine(); + + if (re_password.equals(password)) { + + System.out.println("\n\nSIGNED IN & PROFILE CREATED SUCCESSFULLY!!"); + + } + + else { + + System.out.println("\n\nPASSWORD DOESN'T MATCH!!"); + + return; + + } + + Alumni_Node temp = new Alumni_Node(fname, lname, email, year, branch, specialization, password, identity_no, + + question); + + if (head == null) { + + head = temp; + + } + + else { + + Alumni_Node ptr = head; + + while (ptr.next != null) { + + ptr = ptr.next; + + } + + ptr.next = temp; + + } + + identity_no++; + + } + +//Alumni Log In + + public int login() { + + int flag = 0; + + Alumni_Node ptr = head; + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t LOGIN \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println("\n\n* This Application is Applicable Only for Cummins Students *"); + + + System.out.print("\nEMAIL : "); + + String email = sc.next(); + + sc.nextLine(); + + System.out.print("\nPASSWORD : "); + + String password = sc.nextLine(); + + if (!email.contains("@cumminscollege.in")) { + + System.out.println("\n\nPLEASE ENTER VALID EMAIL ID!"); + + return 0; + + } + + while (ptr != null) { + + if (email.equals(ptr.email) + + && password.equals(ptr.password)) { + + flag = ptr.identity_no; + + break; + + } + + else if (email.equals(ptr.email)) { + + System.out.println("\nIncorrect Password!!"); + + System.out.print("\nForget Password? (YES/NO) : "); + + String s1 = sc.next(); + sc.nextLine(); + + String s = s1.toUpperCase(); + + if (s.equals("YES")) { + + System.out.println("\n\nAnswer your security question?"); + + System.out.println("\nWhat was your favorite food as a child?"); + + String ans = sc.nextLine(); + + if (ans.equals(ptr.question)) { + + System.out.println( + + "\n\n* Your Password Must Contain 8 Characters, Atleast One Must Be of Upper Case, Lower Case, Number and a Special Character *"); + + System.out.print("\n\nSET PASSWORD : "); + + System.out.print("\n\nENTER NEW PASSWORD TO SET : "); + + String newpassword = sc.nextLine(); + + boolean output = isPasswordValid(newpassword); + + while (!output) { + + System.out.println("\n\nINVALID PASSWORD. Please try again."); + + System.out.print("\n\nEnter a password again : "); + + newpassword = sc.nextLine(); + + if (isPasswordValid(newpassword)) { + + System.out.println("\n\nPassword Is Valid."); + + output = true; + + } + + } + + ptr.password = newpassword; + + flag = ptr.identity_no; + + break; + + } + + else { + + System.out.println("\nThat is an incorrect Answer\nPLease try again"); + + return 0; + + } + + } + + else { + return 0; + } + } + + else if (email.equals(ptr.email) && password.equals(ptr.password)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + else if (email.equals(ptr.email)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + else if (password.equals(ptr.password)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + ptr = ptr.next; + + } + + if (flag == 0) { + + System.out.println("\n\nACCOUNT NOT FOUND!\nMAKE SURE YOU HAVE SIGNED IN."); + + } + + return flag; + + } + +//Alumni Profile Update + + public void update(int id) + + { + + Alumni_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity_no == id) { + + break; + + } + + ptr = ptr.next; + + } + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t UPDATE PROFILE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + int year1; + + try { + + System.out.print("\nPASSING YEAR : "); + + year1 = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + year1 = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.print("\nBRANCH : "); + + String branch1 = sc.nextLine(); + + value = onlyAlphabets(branch1); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + branch1 = sc.nextLine(); + + value = onlyAlphabets(branch1); + + } + + System.out.print("\nYOUR SPECIALIZATIONS : "); + + String specialization1 = sc.nextLine(); + + value = onlyAlphabets(specialization1); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + specialization1 = sc.nextLine(); + + value = onlyAlphabets(specialization1); + + } + + ptr.branch = branch1; + + ptr.year = year1; + + ptr.description = specialization1; + + System.out.println("\n\nPROFILE UPDATED SUCCESSFULLY!!"); + + } + + // Method to view own profile + public void view_profile(int id) { + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR PROFILE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t _______________________________________\t\t\t\t\n\n"); + + Alumni_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity_no == id) { + + break; + + } + + ptr = ptr.next; + + } + + System.out.println("\n\nNAME : " + ptr.fname + " " + ptr.lname); + + System.out.println("\nBRANCH : " + ptr.branch); + + System.out.println("\nYEAR : " + ptr.year); + + System.out.println("\nSPECIALIZATIONS : " + ptr.description); + + } + +//Method To Display Recommendations To Student + + String str; + + public int show_student() { + + int flag = 0; + + String str1 = ""; + + Alumni_Node ptr = head; + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t CONNECT \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println("\n\nEnter Details for Recommendations"); + + int year; + + try { + + System.out.print("\nPASSING YEAR : "); + + year = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + year = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.print("\nBRANCH : "); + + String branch = sc.nextLine(); + + boolean value = onlyAlphabets(branch); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + branch = sc.nextLine(); + + value = onlyAlphabets(branch); + + } + + System.out.print("\nSPECIALIZATIONS : "); + + String specialization = sc.nextLine(); + + value = onlyAlphabets(specialization); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + specialization = sc.nextLine(); + + value = onlyAlphabets(specialization); + + } + + while (ptr != null) { + + if (year == ptr.year && ptr.branch.contains(branch) && ptr.description.contains(specialization)) { + + System.out.println("\n\nUnique Identity No. : " + ptr.identity_no); + + System.out.println("\nNAME : " + ptr.fname + " " + ptr.lname); + + System.out.println("BRANCH : " + ptr.branch); + + System.out.println("PASSING YEAR : " + ptr.year); + + System.out.println("SPECIALIZATIONS : " + ptr.description); + + str1 += (ptr.identity_no + " "); + + flag = 1; + + } + + ptr = ptr.next; + + } + + if (flag == 0) { + + System.out.println("\n\nNO RESULTS FOUND!"); + + return 0; + + } + + System.out.print("\n\nDo you Want to Connect? (YES/NO) : "); + + String op1 = sc.next(); + + value = onlyAlphabets(op1); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + op1 = sc.next(); + + value = onlyAlphabets(op1); + + } + + String op = op1.toUpperCase(); + + str = str1; + + return connect(op); + + } + +//Method to check if entered Identity No Is Valid + + public int connect(String op) { + + while (true) { + + if (op.equals("YES")) { + + int id; + + try { + + System.out.print("\n\nEnter Unique Identity NO. to Connect : "); + + id = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + id = sc.nextInt(); + + sc.nextLine(); + + } + + //int f = 0; + + if (check(id, str) == 1) { + + Alumni_Node p = head; + + while (p != null) { + + if (p.identity_no == id) { + + return p.identity_no; + + } + + p = p.next; + + } + + } +/* + if (f == 0) { + + System.out.print("\n\nDo you Want to Connect? (YES/NO) : "); + + String op1 = sc.next(); + + value = onlyAlphabets(op1); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + op1 = sc.next(); + + value = onlyAlphabets(op1); + + } + + op = op1.toUpperCase(); + + if (op.equals("NO")) + + { + + return 0; + + } + + }*/ + + } + + else { + + return 0; + + } + + } + + } + +//Method To Display Alumni As Connections To The Student + + public void display_alumni(String alumni_ids) { + + String[] alumniIdArray = alumni_ids.split(" "); // Splits the string into array of strings + + for (int i = 0; i < alumniIdArray.length; i++) { + + String alumniIdstr = alumniIdArray[i]; + + int alumniId = Integer.parseInt(alumniIdstr); + + Alumni_Node ptr = head; + + int flag = 0; + + while (ptr != null) { + + if (ptr.identity_no == alumniId) { + + System.out.println("\n\nUnique Identity No. : " + ptr.identity_no); + + System.out.println("\nNAME : " + ptr.fname + " " + ptr.lname); + + System.out.println("BRANCH : " + ptr.branch); + + System.out.println("PASSING YEAR : " + ptr.year); + + System.out.println("SPECIALIZATIONS : " + ptr.description); + + flag = 1; + + } + + if (flag == 1) { + + break; + + } + + ptr = ptr.next; + + } + + } + + } + +//Method To Display And Send Messages To Student Connections + // returns choice + + public int alumni_messages() { + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t MESSAGES \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + while (true) { + + System.out.println("\n\n1) MESSAGES\n2) EXIT "); + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + int choice = sc.nextInt(); + + return choice; + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + int choice = sc.nextInt(); + + sc.nextLine(); + + return choice; + + } + + } + + } + +//Method To Return Name Aligned To A Identity No for messages sender name + + public String alumni_name(int id) { + + Alumni_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity_no == id) { + + return (ptr.fname + " " + ptr.lname); + + } + + ptr = ptr.next; + + } + + return null; + + } + +//Method to Check If User Enters Only Among The Displayed Identity No + + public int check(int id, String alumni_ids) { + + String[] alumniIdArray = alumni_ids.split(" "); // Splits the string into array of strings + + for (int i = 0; i < alumniIdArray.length; i++) { + + String alumniIdstr = alumniIdArray[i]; + + int alumniId = Integer.parseInt(alumniIdstr); + + if (id == alumniId) { + + return 1; + + } + + } + + System.out.println("\nINVALID IDENTITY NO.!!"); + + return 0; + + } + +//Method To Check If The String Only Contains Alphabets + + boolean onlyAlphabets(String str) { + + int n = str.length(); + + for (int i = 0; i < n; i++) { + + if (!Character.isAlphabetic(str.charAt(i)) && str.charAt(i) != ' ' && str.charAt(i) != ',') { + + return false; + + } + + } + + return true; + + } + +//Method To Check If The Password Is Valid + + private boolean isPasswordValid(String password) { + + int minLength = 8; + + int maxLength = 15; + + boolean hasUppercase = false; + + boolean hasLowercase = false; + + boolean hasDigit = false; + + boolean hasSpecialChar = false; + + for (char c : password.toCharArray()) { + + if (Character.isUpperCase(c)) { + + hasUppercase = true; + + } else if (Character.isLowerCase(c)) { + + hasLowercase = true; + + } else if (Character.isDigit(c)) { + + hasDigit = true; + + } else if (!Character.isWhitespace(c)) { + + hasSpecialChar = true; + + } + + } + + return password.length() >= minLength && password.length() <= maxLength && hasUppercase && hasLowercase + + && hasDigit && hasSpecialChar; + + } + + int identity_no = 1; + + Alumni_Node temp; + +} \ No newline at end of file diff --git a/1_GirlsCode_Student-Alumni-Networking-Platform/Main.java b/1_GirlsCode_Student-Alumni-Networking-Platform/Main.java new file mode 100644 index 0000000..9efd9b3 --- /dev/null +++ b/1_GirlsCode_Student-Alumni-Networking-Platform/Main.java @@ -0,0 +1,1105 @@ +package miniProject; + +import java.util.*; + +import alumni.Alumni_Profile; + +import student.Student; + +//Message Node Class + +class Message_node { + + String content; + + String student; + + String alumni; + + Message_node next; + + Message_node(String content, String student, String alumni) { + + this.content = content; + + this.student = student; + + this.alumni = alumni; + + this.next = null; + + } + +} + +//Message Methods Class + +class Message { + + boolean value; + + Scanner sc = new Scanner(System.in); + + private Message_node head; + + Message() { + + head = null; + + } + + Message_node ptr; + +//Method To Check If The String Only Contains Alphabets + + public boolean onlyAlphabets(String str) { + + int n = str.length(); + + for (int i = 0; i < n; i++) { + + if (!Character.isAlphabetic(str.charAt(i))) { + + return false; + + } + + } + + return true; + + } + +//Method To Display Received and Sent Messages + + void display_msg(String student_name, String alumni_name) { + + ptr = head; + + int flag = 0; + + while (ptr != null) { + + if (ptr.student.equals(student_name) && ptr.alumni.equals(alumni_name)) { + + System.out.println(ptr.content); + + flag = 1; + + } + + ptr = ptr.next; + + } + + if (flag == 0) { + + System.out.println("\n\nNO CONVERSATIONS YET!!"); + + } + + } + +//Method To Send Message to Alumni + + void send_student(String student_name, String alumni_name) { + + ptr = head; + + display_msg(student_name, alumni_name); + + System.out.print("\nMESSAGE : "); + + String message = student_name + " : " + sc.nextLine() + "\n"; + + Message_node temp = new Message_node(message, student_name, alumni_name); + + if (head == null) { + + head = temp; + + } else { + + ptr = head; + + while (ptr.next != null) { + + ptr = ptr.next; + + } + + ptr.next = temp; + + temp.next = null; + + } + + } + +//Method to send Message to Student + + void send_alumni(String student_name, String alumni_name) { + + ptr = head; + + display_msg(student_name, alumni_name); + + System.out.print("\nMESSAGE : "); + + String message = alumni_name + " : " + sc.nextLine() + "\n"; + + Message_node temp = new Message_node(message, student_name, alumni_name); + + if (head == null) { + + head = temp; + + } else { + + ptr = head; + + while (ptr.next != null) { + + ptr = ptr.next; + + } + + ptr.next = temp; + + temp.next = null; + + } + + } + +} + +//Graph Class + +class Graph { + +//We use Hashmap to store the edges in the graph + + private Map> map = new HashMap<>(); + private Map> map1 = new HashMap<>(); + +//This function adds a new vertex to the graph + + public void addVertex(T s) { + + map1.put(s, new LinkedList()); + + } + + public void addVertex1(T s) { + + map.put(s, new LinkedList()); + + } + + String rejected_ids = ""; + + public int send_notification(T student_id, T alumni_id) { + + if (!map1.containsKey(student_id)) { + addVertex(student_id); + } + if (!map1.containsKey(alumni_id)) { + addVertex(alumni_id); + } + + List studentList = map1.get(alumni_id); + + if (studentList == null) { + studentList = new ArrayList<>(); + map1.put(alumni_id, studentList); + } + + for (T w : studentList) { + if (w.equals(student_id)) { + System.out.println("\n\nPending request!!"); + return 1; + } + } + + String[] split_rejected_ids = rejected_ids.split(" "); + for (String rejectedIdstr : split_rejected_ids) { + + if (rejectedIdstr.equals(student_id)) { + System.out.println("\n\nPending request!!"); + return 1; + } + + } + + studentList.add(student_id); + + return 0; + + } + + public String show_notification(T alumni_id) { + String ids = ""; + + if (map1.containsKey(alumni_id)) { + List studentList = map1.get(alumni_id); + if (studentList != null && !studentList.isEmpty()) { + for (T studentId : studentList) { + ids += studentId.toString() + " "; + } + } + } + + ids = ids.trim(); + + return ids; + } + +//This function adds the edge between source to destination + + public void addEdge(T source, T destination) { + + if (!map.containsKey(source)) + + addVertex1(source); + + if (!map.containsKey(destination)) + + addVertex1(destination); + + for (T w : map.get(source)) { + + if (w == destination) + + { + + System.out.println("\n\nYOU BOTH ARE ALREADY A CONNECTION!!"); + + return; + + } + + } + + map.get(source).add(destination); + + map.get(destination).add(source); + + } + + public void reject_request(String ids, T alumni_id) { + + if (ids.contains(",")) { + + String[] split_connect_ids = ids.split(","); + + for (String studentIdstr : split_connect_ids) { + studentIdstr = studentIdstr.trim(); + + if (!studentIdstr.isEmpty() && studentIdstr.matches("\\d+")) { + Integer studentId = Integer.parseInt(studentIdstr); + + if (map1.containsKey(alumni_id)) { + List studentList = map1.get(alumni_id); + studentList.remove((T) studentId); + } + + rejected_ids += studentIdstr + " "; + System.out.println("Student ID " + studentId + " rejected"); + } + + else { + System.out.println("\n\nInvalid Unique ID"); + } + } + } + + else { + + ids = ids.trim(); + + if (!ids.isEmpty() && ids.matches("\\d+")) { + + Integer studentId = Integer.parseInt(ids); + + if (map1.containsKey(alumni_id)) { + List studentList = map1.get(alumni_id); + studentList.remove((T) studentId); + } + + rejected_ids += ids + " "; + System.out.println("Student ID " + studentId + " rejected"); + } + + else { + System.out.println("\n\nInvalid Unique ID"); + } + } + } + + public void accept_request(String ids, T alumni_id) { + + if (ids.contains(",")) { + + String[] split_connect_ids = ids.split(","); + + for (String studentIdstr : split_connect_ids) { + + studentIdstr = studentIdstr.trim(); + + if (!studentIdstr.isEmpty() && studentIdstr.matches("\\d+")) { + + int studentId = Integer.parseInt(studentIdstr); + T studentIdT = (T) Integer.valueOf(studentId); + addEdge(alumni_id, studentIdT); + + } else { + + System.out.println("Invalid ID: " + studentIdstr); + + } + + } + + } else { + + ids = ids.trim(); + + if (!ids.isEmpty() && ids.matches("\\d+")) { + + int studentId = Integer.parseInt(ids); + T studentIdT = (T) Integer.valueOf(studentId); + addEdge(alumni_id, studentIdT); + + } else { + + System.out.println("Invalid ID: " + ids); + + } + + } + + if (ids.contains(",")) { + + String[] split_connect_ids = ids.split(","); + + for (String studentIdstr : split_connect_ids) { + + studentIdstr = studentIdstr.trim(); + + if (!studentIdstr.isEmpty() && studentIdstr.matches("\\d+")) { + + Integer studentId = Integer.parseInt(studentIdstr); + + if (map1.containsKey(alumni_id)) { + List studentList = map1.get(alumni_id); + studentList.remove((T) studentId); + } + + rejected_ids += studentIdstr + " "; + System.out.println("Student ID " + studentId + " accepted"); + } + + else { + System.out.println("\n\nInvalid Unique ID"); + } + } + } else { + + ids = ids.trim(); + + if (!ids.isEmpty() && ids.matches("\\d+")) { + Integer studentId = Integer.parseInt(ids); + + if (map1.containsKey(alumni_id)) { + List studentList = map1.get(alumni_id); + studentList.remove((T) studentId); + } + + rejected_ids += ids + " "; + System.out.println("Student ID " + studentId + " accepted"); + } + + else { + System.out.println("\n\nInvalid Unique ID"); + } + } + + System.out.println("\n\nCONNECTION ESTABLISHED SUCCESSFULLY!!"); + + } + +// Prints the adjancency list of each vertex. + + public String display(T id) { + + String str = ""; + + try { + if (map.containsKey(id)) { + + for (T w : map.get(id)) { + + str += (w.toString() + " "); + + } + + } + } + + catch (Exception e) { + return str; + } + + return str; + + } + +} + +//MAIN CLASS + +public class Main { + + public static void main(String args[]) { + + Graph g = new Graph(); + + Student obj = new Student(); + + Alumni_Profile obj1 = new Alumni_Profile(); + + Message mess = new Message(); + + Scanner sc = new Scanner(System.in); + + System.out.println("\n\n\t\t\t\t\t\t\t -----------------------------------------------------\t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t STUDENT ALUMNI NETWORKING PLATFORM \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t -----------------------------------------------------\t\t\t\t"); + + System.out.println("\n\n\t\t\t\t\t\t ____________________||PROJECT IS MADE BY||____________________\t\t\t"); + + System.out.println( + + "\n\n\n\t\t\t\t\t\t\t\t\t TANUSHREE KADUS 530\n\n\t\t\t\t\t\t\t\t\t SRUSHTI KAGE 531\n\n\t\t\t\t\t\t\t\t\t RISHITA KHANDAGALE 542\n\n\n\n\n\n"); + System.out.println("Press Enter to Continue!!"); + + try { + + System.in.read(); + + } catch (Exception e) { + + } + + while (true) { + + System.out.println( + + "\n\n\n\n\n\t\t\t\t\t\t************************ WELCOME TO ALUMNI CONNECT ************************\n\n"); + + System.out.println("\n\n\n1) LOGIN\n2) SIGN IN\n3) EXIT"); + + int ch; + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + ch = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + ch = sc.nextInt(); + + sc.nextLine(); + + } + + switch (ch) { + + case 1: + + System.out.println("\n\nWho Are You?\n\n1) STUDENT\n2) ALUMNI"); + + int num; + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + num = sc.nextInt(); + + sc.nextLine(); + + } + + catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + num = sc.nextInt(); + + sc.nextLine(); + + } + + if (num == 1) { + + int student_id = obj.log_in(); // Student's id no + + if (student_id != 0) { + + System.out.println("\n\nSUCCESSFULLY LOGGED IN!!"); + + while (true) { + + System.out.println( + + "\n\n\n\n\n\t\t\t\t\t\t\t\t STUDENT'S PAGE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out + + .println( + + "\n\n1) SEARCH FOR ALUMNI\n2) SEE YOUR CONNECTIONS\n3) MESSAGES\n4) UPDATE YOUR PROFILE\n5) VIEW PROFILE\n6) LOG OUT"); + + System.out.print("\nPlease Enter Appropriate Option : "); + + int ch1 = sc.nextInt(); + + if (ch1 == 6) { + + break; + + } + + switch (ch1) { + + case 1: + + int alumni_id = obj1.show_student(); // Alumni's id no + + if (alumni_id == 0) { + + break; + + } + + if (g.send_notification(student_id, alumni_id) == 0) { + System.out.println("\nRequest Sent!!"); + } + + String op; + + do { + + System.out.print("\n\nWant to make more Connections? (YES/NO) : "); + + String op1 = sc.next(); + op = op1.toUpperCase(); + + alumni_id = obj1.connect(op); + + if (alumni_id == 0) { + break; + } + + if (alumni_id != 0) { + + if (g.send_notification(student_id, alumni_id) == 0) { + System.out.println("\nRequest Sent!!"); + } + + } + + } while (op.equals("YES")); + + break; + + case 2: + + String ans = g.display(student_id); + + if (ans == "") { + + System.out.println("\n\nYOU HAVE NO CONNECTIONS!!"); + + break; + + } + + System.out.println( + "\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR CONNECTIONS \t\t\t\t"); + + System.out.println( + "\t\t\t\t\t\t\t\t ___________________________________\t\t\t\t\n\n"); + + obj1.display_alumni(ans); + + break; + + case 3: + + int ch2 = obj.student_messages(); // Return choice + + switch (ch2) { + + case 1: + + String ans1 = g.display(student_id); + + if (ans1 == "") { + + System.out.println("\n\nYOU HAVE NO CONNECTIONS!!"); + + break; + + } + + System.out.println( + "\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR CONNECTIONS \t\t\t\t"); + + System.out.println( + "\t\t\t\t\t\t\t\t ___________________________________\t\t\t\t\n\n"); + + obj1.display_alumni(ans1); + + System.out.print("\n\nEnter Unique Identity No. of Alumni to Message : "); + + int alumni = sc.nextInt(); + + int c = obj1.check(alumni, ans1); + + if (c == 0) { + + break; + + } + + String std_name = obj.student_name(student_id); + + String alumni_name = obj1.alumni_name(alumni); + + String a = alumni_name.toUpperCase(); + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t " + a + + " \t\t\t\t"); + + System.out.println( + "\t\t\t\t\t\t\t\t _____________________________\t\t\t\t\n\n"); + + mess.send_student(std_name, alumni_name); + + break; + + case 2: + + break; + + } + + break; + + case 4: + + obj.update(student_id); + + break; + + case 5: + + obj.view_profile(student_id); + + break; + + default: + + System.out.println("\n\nEnter a Valid Option!"); + + } + + } + + } + + } + + else if (num == 2) { + + int alumni_id = obj1.login(); + + if (alumni_id != 0) { + + System.out.println("\n\nSUCCESSFULLY LOGGED IN!!"); + + while (true) { + + System.out.println( + + "\n\n\n\n\n\t\t\t\t\t\t\t\t ALUMNI'S PAGE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println( + + "\n\n1) UPDATE YOUR PROFILE\n2) VIEW PROFILE\n3) SEE YOUR CONNECTIONS\n4) MESSAGES\n5) NOTIFICATIONS \n6) LOG OUT "); + + int ch1; + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + ch1 = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + ch1 = sc.nextInt(); + + sc.nextLine(); + + } + + if (ch1 == 6) { + + break; + + } + + switch (ch1) { + + case 1: + + obj1.update(alumni_id); + + break; + + case 2: + + obj1.view_profile(alumni_id); + + break; + + case 3: + + String ans1 = g.display(alumni_id); + + if (ans1 == "") { + + System.out.println("\n\nYOU HAVE NO CONNECTIONS!!"); + + break; + + } + + System.out.println( + "\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR CONNECTIONS \t\t\t\t"); + + System.out.println( + "\t\t\t\t\t\t\t\t ___________________________________\t\t\t\t\n\n"); + + obj.display_student(ans1); + + break; + + case 4: + + int ch2 = obj1.alumni_messages(); + + switch (ch2) { + + case 1: + + ans1 = g.display(alumni_id); + + if (ans1 == "") { + + System.out.println("\n\nYOU HAVE NO CONNECTIONS!!"); + + break; + + } + + System.out.println( + "\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR CONNECTIONS \t\t\t\t"); + + System.out.println( + "\t\t\t\t\t\t\t\t ___________________________________\t\t\t\t\n\n"); + + obj.display_student(ans1); + + int student; + + try { + + System.out.print("\n\nEnter Unique Identity No. of Student to Message : "); + + student = sc.nextInt(); + + sc.nextLine(); + + } + + catch (Exception e) { + + System.out.println("Enter Digits Only"); + + System.out.println("Re-Enter"); + + sc.nextLine(); + + student = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.println("\n\n"); + + int c = obj.check(student, ans1); + + if (c == 0) { + + break; + + } + + String std_name = obj.student_name(student); + + String s = std_name.toUpperCase(); + + String alumni_name = obj1.alumni_name(alumni_id); + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t " + s + " \t\t\t\t"); + System.out.println("\t\t\t\t\t\t\t\t _____________________________\t\t\t\t\n\n"); + + mess.send_alumni(std_name, alumni_name); + + break; + + case 2: + + break; + + } + + break; + + case 5: + + String ids; + + ids = g.show_notification(alumni_id); + + if (ids.equals("")) { + System.out.println("\n\nNO NOTIFICATIONS!!"); + break; + } + + obj.student_name(ids); + + int choice; + + do { + System.out.println( + "\nDo you want to....\n\n1. ACCEPT REQUEST\n2. REJECT REQUEST\n3. EXIT"); + System.out.print("\nEnter your choice : "); + choice = sc.nextInt(); + switch (choice) { + case 1: + String connect_ids = ""; + + System.out.print("\nEnter Unique IDs you want to connect with:"); + + sc.nextLine(); + + connect_ids = sc.nextLine().trim(); // Trim the input string + + String notification_id = g.show_notification(alumni_id); + + String[] accepted_ids_array = connect_ids.split(","); + + boolean allacceptedIDsFound = true; + + for (String rejected_id : accepted_ids_array) { + + if (!notification_id.contains(rejected_id)) { + + allacceptedIDsFound = false; + break; + } + } + + if (allacceptedIDsFound) { + g.accept_request(connect_ids, alumni_id); + } + + else { + System.out.print("\nReEnter Unique IDs you want to Reject :"); + connect_ids = sc.nextLine().trim(); + + g.accept_request(connect_ids, alumni_id); + + } + + break; + + case 2: + + String reject_ids = ""; + + System.out.print("\nEnter Unique IDs you want to Reject :"); + sc.nextLine(); + reject_ids = sc.nextLine().trim(); + + String notification_ids = g.show_notification(alumni_id); + + String[] rejected_ids_array = reject_ids.split(","); + + boolean allRejectedIDsFound = true; + + for (String rejected_id : rejected_ids_array) { + + if (!notification_ids.contains(rejected_id)) { + + allRejectedIDsFound = false; + break; + } + } + + if (allRejectedIDsFound) { + + g.reject_request(reject_ids, alumni_id); + } + + else { + + System.out.print("\nReEnter Unique IDs you want to Reject :"); + + reject_ids = sc.nextLine().trim(); + + g.reject_request(reject_ids, alumni_id); + + } + + break; + + default: + + System.out.println("\n\nEnter a Valid Option!!"); + + } + + } while (choice != 3); + + } + + } + + } + } + + else { + + System.out.println("\n\nEnter a Valid Option!!"); + + } + + break; + + case 2: + + System.out.println("\n\nWho Are You?\n\n1) STUDENT\n2) ALUMNI"); + + int num1; + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + num1 = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.println("\nRe-Enter : "); + + sc.nextLine(); + + num1 = sc.nextInt(); + + sc.nextLine(); + + } + + if (num1 == 1) { + + obj.sign_up(); + + } + + else if (num1 == 2) { + + obj1.signup(); + + } + + else { + + System.out.println("\nEnter a Valid Option!"); + + } + + break; + + case 3: + + System.out.println( + + "\n\n\n\n\n\n\n\n\t\t\t\t\t\t ***************************** THANK YOU *****************************\n\n"); + + System.out.println("\t\t\t\t\t\t\t We Hope We've Connected You To Your Desired Mentors"); + + System.out.println("\t\t\t\t\t\t And Being An Alumni It's Always A Bliss Reconnecting To Your Roots."); + + return; + + default: + + System.out.println("\n\nEnter a Valid Option!!"); + + } + + } + + } + +} diff --git a/1_GirlsCode_Student-Alumni-Networking-Platform/README.md b/1_GirlsCode_Student-Alumni-Networking-Platform/README.md new file mode 100644 index 0000000..46e070c --- /dev/null +++ b/1_GirlsCode_Student-Alumni-Networking-Platform/README.md @@ -0,0 +1,64 @@ +# Student - Alumni Networking Platform + +Student-Alumni Networking Platform, a medium to bridge the gap between past, present, and future generations of our esteemed academic community. This platform is designed to connect students and graduates, across various fields, fostering a vibrant ecosystem of knowledge sharing, mentorship, and collaboration. + +This platform is not just a space for networking; it's a thriving community driven by the collective ambition to learn, grow, and succeed together. + +This project is structured into three different packages namely miniproject, Student, Alumni for easy accessibility of required methods. + + +## Table of Contents +- [Installation](#installation) +- [Features](#features) +- [Data Structures Implemented](#data-structures-implemented) + +## Installation + +To install this project, follow these steps: + + 1. Clone the repository. + 2. Navigate to the project directory. + 3. Run `` + npm install + `` + to install dependencies. + + + +## Features + +- User Account Creation (SIGN UP) +- User Account Login (LOG IN) +- [Student Dashboard](#student-dashboard) +- [Alumni Dashboard](#alumni-dashboard) + + +## Student Dashboard +1. Search and Connect with Alumni +2. See Your Connections +3. Send Messages to Your Connections +4. Update Your Profile +5. View Profile +6. Log Out +## Alumni Dashboard +1. Update Your Profile. +2. View Profile +3. See Your Connections. +4. Send Messages to Your Connections. +5. Notifications +6. Log Out. +## Data Structures Implemented +We have thoughtfully selected data structures based on their dynamic nature, suitability, and time complexity: + +1. Linked List: Used for dynamically storing student and alumni data, facilitating the creation of accounts, and efficient data management. +2. Graph: Graphs are employed to create and manage connections between students and alumni, similar to professional networking platforms, enabling messaging after connections are established. +3. Hash Map: Hash maps are used to map identity numbers to lists of connections for each user. We preferred hash maps over arrays as the arrays are static in nature, and over arraylists as arraylist allows duplicate keys. +4. Arrays: Identity no of Connections of a user are stored in a String with spaces; then the String is split using the split() function into an Array of Strings which is then traversed to print details of connections. +5. Exception handling has been implemented to enhance application robustness. + +## Video Link +https://drive.google.com/file/d/1sQBRx-wUQcFDqvPIzOMW5kWbjUgF3jW-/view?usp=drivesdk + +## Reports +Report 1 - https://drive.google.com/file/d/10DFIw_kwLeYXEZvd78Gp-KF0qB2Vfw7N/view?usp=sharing +Report 2 - https://drive.google.com/file/d/10I29qFO_DuPgPYhM0nmEbbzyacxRiOB-/view?usp=sharing diff --git a/1_GirlsCode_Student-Alumni-Networking-Platform/Student.java b/1_GirlsCode_Student-Alumni-Networking-Platform/Student.java new file mode 100644 index 0000000..78f99e1 --- /dev/null +++ b/1_GirlsCode_Student-Alumni-Networking-Platform/Student.java @@ -0,0 +1,788 @@ +package student; + +import java.util.ArrayList; +import java.util.Scanner; + +import alumni.Alumni_Profile; +//Student Node class + +class Student_Node { + + Student_Node next; + + String fname; + + String lname; + + String email; + + String password; + + int identity; + + String question; + + String branch; + + int year; + + Student_Node(String fname, String lname, String email, String password, int identity, String question, + + String branch, int year) { + + this.fname = fname; + + this.lname = lname; + + this.email = email; + + this.password = password; + + this.identity = identity; + + this.question = question; + + this.branch = branch; + + this.year = year; + + this.next = null; + + } + +} +//Student Methods Class + +public class Student { + + Scanner sc = new Scanner(System.in); + + boolean value; + + private Student_Node head; + + public Student() { + + head = null; + + } +//Student Sign Up + + public void sign_up() { + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t SIGN IN \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println("\n\n* This Application is Applicable Only for Cummins Students *"); + + System.out.print("\n\nFIRST NAME : "); + + String fname = sc.next(); + + value = onlyAlphabets(fname); + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + fname = sc.next(); + + value = onlyAlphabets(fname); + + } + + System.out.print("\nLAST NAME : "); + + String lname = sc.next(); + + value = onlyAlphabets(lname); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + lname = sc.next(); + + value = onlyAlphabets(lname); + + } + + System.out.print("\nEMAIL : "); + + String email = sc.next(); + + sc.nextLine(); + + if (!email.contains("@cumminscollege.in")) { + + System.out.println("\n\nPLEASE ENTER VALID EMAIL ID!"); + + return; + + } + + if (head == null) { + + head = temp; + + } + + else { + + Student_Node ptr = head; + + boolean emailexits = false; + + while (ptr != null) { + + if (email.equals(ptr.email)) { + + emailexits = true; + + break; + + } + + ptr = ptr.next; + + } + + if (emailexits) { + + System.out.println("\n\nYOU HAVE ALREADY SIGNED!!"); + + return; + + } + + } + + System.out.print("\nBRANCH : "); + + String branch = sc.nextLine(); + value = onlyAlphabets(branch); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + branch = sc.nextLine(); + + value = onlyAlphabets(branch); + + } + + int year; + + try { + + System.out.print("\nCURRENT YEAR OF STUDY : "); + + year = sc.nextInt(); + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + year = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.println("\n\nSecurity Question : "); + + System.out.println("\nWhat was your favorite food as a child?"); + + String question = sc.nextLine(); + + value = onlyAlphabets(question); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + question = sc.nextLine(); + + value = onlyAlphabets(question); + + } + + System.out.println( + + "\n\n* Your Password Must Contain 8 Characters, Atleast One Must Be of Upper Case, Lower Case, Number and a Special Character *"); + + System.out.print("\n\nSET PASSWORD : "); + + String password = sc.nextLine(); + + boolean output = isPasswordValid(password); + + while (!output) { + + System.out.println("\n\nINVALID PASSWORD. Please try again."); + + System.out.print("\n\nEnter a password again : "); + + password = sc.nextLine(); + + if (isPasswordValid(password)) { + + System.out.println("\n\nPassword Is Valid."); + + output = true; + + } + + } + + System.out.print("\n\nCONFIRM PASSWORD : "); + + String re_password = sc.nextLine(); + + if (re_password.equals(password)) { + + System.out.println("\n\nACCOUNT CREATED SUCCESSFULLY!!"); + + } + + else { + + System.out.println("\n\nPASSWORD DOESN'T MATCH!!"); + + return; + + } + + Student_Node temp = new Student_Node(fname, lname, email, password, identity, question, branch, year); + + if (head == null) { + + head = temp; + + } + + else { + + Student_Node ptr = head; + + while (ptr.next != null) { + + ptr = ptr.next; + + } + + ptr.next = temp; + + } + + identity++; + + } +//Student Log In + + public int log_in() { + + int flag = 0; + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t LOGIN \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + System.out.println("\n\n* This Application is Applicable Only for Cummins Students *"); + + + System.out.print("\nEMAIL : "); + + String email = sc.next(); + + sc.nextLine(); + + System.out.print("\nPASSWORD : "); + + String password = sc.nextLine(); + + if (!email.contains("@cumminscollege.in")) { + + System.out.println("\n\nPLEASE ENTER VALID EMAIL ID!"); + + return 0; + + } + + Student_Node ptr = head; + + while (ptr != null) { + + if (email.equals(ptr.email) + + && password.equals(ptr.password)) { + + flag = ptr.identity; + + break; + + } + + else if (email.equals(ptr.email)) { + + System.out.println("\nIncorrect Password!!"); + + System.out.print("\nForget Password? (YES/NO) : "); + + String s1 = sc.next(); + sc.nextLine(); + + String s = s1.toUpperCase(); + + if (s.equals("YES")) { + + System.out.println("\n\nAnswer your security question?"); + + System.out.println("\nWhat was your favorite food as a child?"); + + String ans = sc.nextLine(); + + if (ans.equals(ptr.question)) { + + System.out.println( + + "\n\n* Your Password Must Contain 8 Characters, Atleast One Must Be of Upper Case, Lower Case, Number and a Special Character *"); + + System.out.print("\n\nENTER NEW PASSWORD TO SET : "); + + String newpassword = sc.nextLine(); + + boolean output = isPasswordValid(newpassword); + + while (!output) { + + System.out.println("\n\nINVALID PASSWORD. Please try again."); + + System.out.print("\n\nEnter a password again : "); + + newpassword = sc.nextLine(); + + if (isPasswordValid(newpassword)) { + + System.out.println("\n\nPassword Is Valid."); + + output = true; + + } + + } + + ptr.password = newpassword; + + flag = ptr.identity; + + break; + + } + + else { + + System.out.println("\nThat is an incorrect Answer\nPLease try again"); + + return 0; + + } + + } + + else { + return 0; + } + + } + + else if (email.equals(ptr.email) && password.equals(ptr.password)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + else if (email.equals(ptr.email)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + else if (password.equals(ptr.password)) { + + System.out.println("\nCREDENTIALS MISMATCHED!"); + + return 0; + + } + + ptr = ptr.next; + + } + + if (flag == 0) { + + System.out.println("\n\nACCOUNT NOT FOUND!\nMAKE SURE YOU HAVE SIGNED IN."); + + } + + return flag; + + } + +//Student Profile Update + public void update(int id) + + { + + Student_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity == id) { + + break; + + } + + ptr = ptr.next; + + } + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t UPDATE PROFILE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + int year1; + + try { + + System.out.print("\nCURRENT YEAR OF STUDY : "); + + year1 = sc.nextInt(); + + sc.nextLine(); + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + year1 = sc.nextInt(); + + sc.nextLine(); + + } + + System.out.print("\nBRANCH : "); + + String branch1 = sc.nextLine(); + + value = onlyAlphabets(branch1); + + while (!value) { + + System.out.println("\n\nEnter Alphabets ONLY!!"); + + System.out.print("\nRe-Enter : "); + + branch1 = sc.nextLine(); + + value = onlyAlphabets(branch1); + + } + + System.out.println("\n\nPROFILE UPDATED SUCCESSFULLY!!"); + + } + + // Method to view own profile + public void view_profile(int id) { + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t YOUR PROFILE \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t _______________________________________\t\t\t\t\n\n"); + + Student_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity == id) { + + break; + + } + + ptr = ptr.next; + + } + + System.out.println("\n\nNAME : " + ptr.fname + " " + ptr.lname); + + System.out.println("\nBRANCH : " + ptr.branch); + + System.out.println("\nYEAR : " + ptr.year); + + } + +//Method To Display And Send Messages To Alumni Connections + // return choice + public int student_messages() { + + System.out.println("\n\n\n\n\n\t\t\t\t\t\t\t\t MESSAGES \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + while (true) { + + System.out.println("\n\n1) MESSAGES\n2) EXIT "); + + try { + + System.out.print("\nPlease Enter Appropriate Option : "); + + int choice = sc.nextInt(); + + return choice; + + } catch (Exception e) { + + System.out.println("\n\nEnter Digits ONLY!!"); + + System.out.print("\nRe-Enter : "); + + sc.nextLine(); + + int choice = sc.nextInt(); + + sc.nextLine(); + + return choice; + + } + + } + + } + +//Method To Display Students As Connections To The Alumni + + public void display_student(String student_ids) { + + String[] studentIdArray = student_ids.split(" "); // Splits the string into array of strings + + for (int i = 0; i < studentIdArray.length; i++) { + + String studentIdstr = studentIdArray[i]; + + int studentId = Integer.parseInt(studentIdstr); + + Student_Node ptr = head; + + int flag = 0; + + while (ptr != null) { + + if (ptr.identity == studentId) { + + System.out.println("\n\nUnique Identity No. : " + ptr.identity); + + System.out.println("\nNAME : " + ptr.fname + " " + ptr.lname); + + System.out.println("BRANCH : " + ptr.branch); + + System.out.println("YEAR : " + ptr.year); + + flag = 1; + + } + + if (flag == 1) { + + break; + + } + + ptr = ptr.next; + + } + + } + + } +//Method To Return Name Aligned To A Identity No to fetch name for messages + + public String student_name(int id) { + + Student_Node ptr = head; + + while (ptr != null) { + + if (ptr.identity == id) { + + return (ptr.fname + " " + ptr.lname); + + } + + ptr = ptr.next; + + } + + return null; + + } + + + public void student_name(String ids) { + + System.out.println( + + "\n\n\n\n\n\t\t\t\t\t\t\t\t NOTIFICATIONS \t\t\t\t"); + + System.out.println("\t\t\t\t\t\t\t\t -----------------------------------\t\t\t\t\n\n"); + + Student_Node ptr = head; + + String[] studentIdArray = ids.split(" "); + + for (int i = 0; i < studentIdArray.length; i++) { + + String studentIdstr = studentIdArray[i]; + + int studentId = Integer.parseInt(studentIdstr); + + while (ptr != null) { + + if (ptr.identity == studentId) { + + System.out.println(); + System.out.println("Unique ID : " + studentId); + System.out.println(ptr.fname + " " + ptr.lname + " has sent you a request\n"); + + break; + } + + ptr = ptr.next; + + } + } + + } + + + +//Method to Check If User Enters Only Among The Displayed Identity No + + public int check(int id, String student_ids) { + + String[] alumniIdArray = student_ids.split(" "); // Splits the string into array of strings + + for (int i = 0; i < alumniIdArray.length; i++) { + + String alumniIdstr = alumniIdArray[i]; + + int alumniId = Integer.parseInt(alumniIdstr); + + if (id == alumniId) { + + return 1; + + } + + } + + System.out.println("INVALID IDENTITY NO.!!"); + + return 0; + + } + + + +//Method To Check If The Password Is Valid + + private boolean isPasswordValid(String password) { + + int minLength = 8; + + int maxLength = 15; + + boolean hasUppercase = false; + + boolean hasLowercase = false; + + boolean hasDigit = false; + + boolean hasSpecialChar = false; + + for (char c : password.toCharArray()) { + + if (Character.isUpperCase(c)) { + + hasUppercase = true; + + } else if (Character.isLowerCase(c)) { + + hasLowercase = true; + + } else if (Character.isDigit(c)) { + + hasDigit = true; + + } else if (!Character.isWhitespace(c)) { + + hasSpecialChar = true; + + } + + } + + return password.length() >= minLength && password.length() <= maxLength && hasUppercase && hasLowercase + + && hasDigit && hasSpecialChar; + + } + + int identity = 100; + + Student_Node temp; + +//Method To Check If The String Only Contains Alphabets + boolean onlyAlphabets(String str) { + + int n = str.length(); + + for (int i = 0; i < n; i++) { + + if (!Character.isAlphabetic(str.charAt(i)) && str.charAt(i) != ' ') { + + return false; + + } + + } + + return true; + + } +} \ No newline at end of file