diff --git a/README.md b/README.md index 910ff0f..761de9a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,42 @@ -# Buffer-5.0 -Buffer is a Data Structures and Algorithms Project Series, in which students can participate as mentees in teams of 2-4. Under Buffer 5.0, the themes on which students can create a project are: -1. Public Welfare -2. Tourism -3. College level applications -4. Custom Data structure +# Cummins Connect -This repository is created for all the teams to be able to upload their final project source code. While submitting, note that all the submission guidelines given are followed, and all the files are named appropiately. Also ensure that your README file contains the links of the progress reports and the drive link containing the video of the project. +To develop a solution to the problem of current students lacking effective means to connect with esteemed alumni from our college, hindering access to valuable guidance and opportunities, Cummins Connect is developed using the concepts of data structure and algorithms to improve the students access to alumni of their college. This solution aims to enhance mentorship and networking within our college community. + +![Screenshot (741)](https://github.com/Swetathakare/Alumni-Connect/assets/143093330/0d9fae5c-3587-4baa-80b6-e9b731aaf20b) + + +## Data Structures Used + + +1. Alumni Database Side: HashMap + -------------------------- + + Hash maps offer efficient lookup and retrieval times, crucial for managing large sets of alumni data. + +2. Alumni Arrangement: Trees (Non-linear) + ------------------- + + Trees facilitate hierarchical organization, allowing for easy navigation and categorization of alumni based on + various attributes. + ![WhatsApp Image 2024-04-30 at 23 11 22_0f65f492](https://github.com/Swetathakare/Alumni-Connect/assets/143093330/1db44c82-f938-4ef7-bf5a-13ad0962597c) + + +4. Student Database Side: Linked List + ---------------- + Linked lists provide flexibility for dynamic data manipulation, making them suitable for managing student profiles. + +5. Post: Array List + --------------- + + Arrays offer constant-time access to elements, making them suitable for storing and retrieving posts efficiently. + + ![WhatsApp Image 2024-04-30 at 23 11 21_fd47c2af](https://github.com/Swetathakare/Alumni-Connect/assets/143093330/24f7ba1b-0e10-459c-857c-db5cf63c766c) + + +## Drive Links + +Drive link to reports - https://drive.google.com/drive/folders/16QytgTrUZU1-pWZAhtDUHEW6Rv-FrNG3 + + +Drive link to video - https://drive.google.com/drive/folders/11TPVyBYEx6EUqWXIUXrv9hcdp7Z_PEts?usp=sharing diff --git a/Team 31 - Cummins Connect/Alumni.java b/Team 31 - Cummins Connect/Alumni.java new file mode 100644 index 0000000..e5f730d --- /dev/null +++ b/Team 31 - Cummins Connect/Alumni.java @@ -0,0 +1,111 @@ +package buffer; + +//import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +class Alumni { + + String name; + + String branch; + + String passingYear; + + String domain; + String password; + String organisation; + + ArrayList tags; + + String id; + String gmail; + String contact; + ArrayList posts = new ArrayList<>(); + + public ArrayList getPosts() { + return posts; + } + + Alumni(String Name, String Branch, String PassingYear, String domain, String organisation, ArrayList Tags, + + String Id, String gmail, String contact ,String password) { + +//this.posts = new ArrayList<>(); + + this.name = Name; + + this.branch = Branch; + + this.passingYear = PassingYear; + + this.domain = domain; + + this.organisation = organisation; + + this.tags = Tags; + + this.id = Id; + + this.gmail = gmail; + + this.contact = contact; + + this.password =password; + } + + + public void displayPost(Post post) { + + System.out.println("-------------------------------------"); + + System.out.println("Post ID: " + post.getId()); + + System.out.println("Post Title: " + post.getTitle()); + + System.out.println("Post Date: " + post.getPostDate()); + + System.out.println("Deadline of Registration: " + post.getDeadlineOfRegistration()); + + System.out.println("Date of Event: " + post.getDateOfEvent()); + + System.out.println("Post Description: " + post.getPostDescription()); + + System.out.println("Tags: " + post.getTags()); + + System.out.println("-------------------------------------"); + + } + + + + public void deletePost() { + + Scanner input = new Scanner(System.in); + + System.out.print("Enter post ID to delete: "); + + String postIdToDelete = input.nextLine(); + + for (int i = 0; i < posts.size(); i++) { + + Post post = posts.get(i); + + if (post.Id.equals(postIdToDelete)) { + + posts.remove(i); + + System.out.println("Post deleted successfully!"); + + return; + + } + + } + + System.out.println("Post not found."); + + } + +} diff --git a/Team 31 - Cummins Connect/AlumniDB.java b/Team 31 - Cummins Connect/AlumniDB.java new file mode 100644 index 0000000..986cc7f --- /dev/null +++ b/Team 31 - Cummins Connect/AlumniDB.java @@ -0,0 +1,727 @@ +package buffer; + +import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Scanner; + + + +class AlumniDB { + + static AlumniTree a = new AlumniTree(""); + public static HashMap alumniMap = new HashMap<>(); + +AlumniDB() { + + // Priya_123 + Alumni alumniPriya_123 = new Alumni("Priya Gupta", "Electrical Engineering", "2015", "Software Engineer", "Microsoft", + new ArrayList<>(Arrays.asList("#coding", "#algorithms")), "Priya_123", "priya@example.com", "1234567890","Priy@987"); + + Post postPriya123_1 = new Post("Priya_1", "Java Coding Bootcamp", "2023-03-15", "2023-03-30", "2023-04-05", + "Join our Java coding bootcamp and master the fundamentals of object-oriented programming.", + new ArrayList<>(Arrays.asList("#Java", "#coding", "#bootcamp"))); + + alumniPriya_123.posts.add(postPriya123_1); + + Post postPriya123_2 = new Post("Priya_2", "Algorithms Study Group", "2023-04-20", "2023-05-05", "2023-05-10", + "Join our algorithms study group to explore advanced algorithms and problem-solving techniques.", + new ArrayList<>(Arrays.asList("#algorithms", "#studygroup", "#problem-solving"))); + + Registration r1=new Registration("ABC1234567", "Riddhi Sharma", "9876543210", "riddhi@xyzcollege.in"); + + Registration r2=new Registration("DEF2345678", "Rohan Desh", "9876543211", "rohan@xyzcollege.in"); + + Registration r3=new Registration("GHI3456789", "Ali Singh", "9876543212", "ali@xyzcollege.in"); + + Registration r4=new Registration("KLE3456789", "Raddha Sharma", "9876543456", "raddha@xyzcollege.in"); + + postPriya123_1.registeredStudents.add(r1); + + postPriya123_1.registeredStudents.add(r2); + + postPriya123_1.registeredStudents.add(r3); + + postPriya123_1.registeredStudents.add(r4); + + alumniPriya_123.posts.add(postPriya123_2); + + // Add Priya_123 to alumniMap + alumniMap.put("Priya_123", alumniPriya_123); + + // Aisha_234 + Alumni alumniAisha_234 = new Alumni("Aisha Khan", "Electrical Engineering", "2018", "Data Analyst", "Microsoft", + new ArrayList<>(Arrays.asList("data analysis", "statistics", "SQL")), "Aisha_234", "aisha@example.com", "9876543210","aisha@123"); + + alumniAisha_234.posts.add(new Post("Aisha_1", "Data Analysis Workshop", "2023-02-25", "2023-03-10", "2023-03-15", + "Join us for an insightful workshop on data analysis.", new ArrayList<>(Arrays.asList("#dataanalysis", "#statistics", "#SQL")))); + alumniAisha_234.posts.add(new Post("Aisha_2", "Mentorship at Microsoft", "2024-04-21", "2024-04-26", "2024-04-04", + "Exclusive mentorship session at Microsoft HYD office for the selected students. Grab the opportunity now.", + new ArrayList<>(Arrays.asList("#Mentorship", "#Microsoft")))); + + alumniMap.put("Aisha_234", alumniAisha_234); + + // Neha_483 + Alumni alumniNeha_483 = new Alumni("Neha Patel", "Mechanical Engineering", "2012", "Product Manager", "Amazon", + new ArrayList<>(Arrays.asList("product management", "leadership", "strategy")), "Neha_483", "neha@example.com", "4567890123","neha*345"); + alumniNeha_483.posts.add(new Post("Neha_1", "Understanding concepts of project management", "2024-05-20", "2024-05-27", "2024-06-15", + "Know insights of project management", new ArrayList<>(Arrays.asList("#projectmanagement", "#amazon")))); + alumniNeha_483.posts.add(new Post("Neha_2", "Effective Leadership Workshop", "2024-06-30", "2024-07-10", "2024-07-15", + "Join our workshop to enhance your leadership skills and learn effective management techniques.", + new ArrayList<>(Arrays.asList("#leadership", "#workshop", "#management")))); + + alumniNeha_483.posts.add(new Post("Neha_3", "Strategic Planning Seminar", "2024-08-15", "2024-08-25", "2024-09-05", + "Participate in our strategic planning seminar to develop your strategic thinking abilities and planning skills.", + new ArrayList<>(Arrays.asList("#strategy", "#planning", "#seminar")))); + + alumniMap.put("Neha_483", alumniNeha_483); + + // Shruti_456 + Alumni alumniShruti_456 = new Alumni("Shruti Singh", "Information Technology", "2019", "Web Developer", "Facebook", + new ArrayList<>(Arrays.asList("web development", "front-end", "JavaScript")), "Shruti_456", "shruti@example.com", "7890123456","shruti#234"); + + alumniShruti_456.posts.add(new Post("Shruti_1", "Exploring Web Development", "2023-05-20", "2023-06-05", "2023-06-10", + "Join us in exploring the exciting world of web development! Learn about HTML, CSS, and JavaScript essentials.", + new ArrayList<>(Arrays.asList("#webdevelopment", "#HTML", "#CSS", "#JavaScript")))); + + alumniShruti_456.posts.add(new Post("Shruti_2", "Mastering Front-end Frameworks", "2023-06-20", "2023-07-05", "2023-07-10", + "Take your front-end development skills to the next level by mastering popular frameworks like React and Angular.", + new ArrayList<>(Arrays.asList("#frontend", "#React", "#Angular")))); + + alumniMap.put("Shruti_456", alumniShruti_456); + + // Pooja_453 + Alumni alumniPooja_453 = new Alumni("Pooja Sharma", "Computer Science", "2016", "Machine Learning Engineer", "Apple", + new ArrayList<>(Arrays.asList("machine learning", "data science", "Python")), "Pooja_453", "pooja@example.com", "2345678901","Poo@123"); + + Post postPooja453 = new Post("Pooja_1", "Embark Your Coding Journey!", "2023-01-25", "2023-02-01", "2023-02-02", + "Dive deep into the world of coding and embark on your coding journey with us!", new ArrayList<>(Arrays.asList("#coding", "#beginner", "#adventure"))); + Post postPooja453_2 = new Post("Pooja_2", "Mastering Data Science", "2023-03-15", "2023-03-30", "2023-04-05", + "Join us to master the fundamentals of data science and unlock the power of Python for analysis!", + new ArrayList<>(Arrays.asList("#datascience", "#Python", "#analytics"))); + Post postPooja453_3 = new Post("Pooja_3", "Advanced Machine Learning Workshop", "2023-05-10", "2023-05-25", "2023-06-01", + "Take your machine learning skills to the next level with our advanced workshop. Dive into complex algorithms and techniques!", + new ArrayList<>(Arrays.asList("#machinelearning", "#advanced", "#workshop"))); + //for postPooja453_3 + + Registration r5=new Registration("PQR5678901", "Priya Gupta", "9876543458", "priya@xyzcollege.in"); + + Registration r6=new Registration("STU6789012", "Aryan Kumar", "9876543459", "aryan@xyzcollege.in"); + + Registration r7=new Registration("GHI3456789", "Ali Singh", "9876543212", "ali@xyzcollege.in"); + + Registration r8=new Registration("KLE3456789", "Raddha Sharma", "9876543456", "raddha@xyzcollege.in"); + + postPooja453_3.registeredStudents.add(r5); + + postPooja453_3.registeredStudents.add(r6); + + postPooja453_3.registeredStudents.add(r7); + + postPooja453_3.registeredStudents.add(r8); + + + alumniPooja_453.posts.add(postPooja453); + alumniPooja_453.posts.add(postPooja453_2); + alumniPooja_453.posts.add(postPooja453_3); + alumniMap.put("Pooja_453", alumniPooja_453); + + // Ritu_376 + Alumni alumniRitu_376 = new Alumni("Ritu Gupta", "Computer Science", "2017", "Software Developer", "TCS", + new ArrayList<>(Arrays.asList("software development", "Java", "databases")), "Ritu_376", "ritu@example.com", "3456789012","RItu*234"); + + Post postRitu376 = new Post("Ritu_1", "Mastering Algorithms", "2023-04-10", "2023-04-15", "2023-04-16", + "Dive deep into the world of algorithms and sharpen your problem-solving skills. Join us on this algorithmic journey!", + new ArrayList<>(Arrays.asList("#algorithms", "#problem-solving", "#data-structures"))); + + Post postRitu376_2 = new Post("Ritu_2", "Exploring Java Development", "2023-05-20", "2023-06-05", "2023-06-10", + "Explore the world of Java development and learn about the latest trends and techniques in building robust software applications!", + new ArrayList<>(Arrays.asList("#Java", "#development", "#coding"))); + + Registration r9=new Registration("PQR5678901", "Priya Gupta", "9876543458", "priya@xyzcollege.in"); + + Registration r10=new Registration("STU6789012", "Aryan Kumar", "9876543459", "aryan@xyzcollege.in"); + + Registration r11=new Registration("VWX7890123", "Neha Singh", "9876543460", "neha@xyzcollege.in"); + + Registration r12=new Registration("YZA8901234", "Amit Jain", "9876543461", "amit@xyzcollege.in"); + + postRitu376_2.registeredStudents.add(r9); + + postRitu376_2.registeredStudents.add(r10); + + postRitu376_2.registeredStudents.add(r11); + + postRitu376_2.registeredStudents.add(r12); + + alumniRitu_376.posts.add(postRitu376); + alumniRitu_376.posts.add(postRitu376_2); + alumniMap.put("Ritu_376", alumniRitu_376); + + // Swati_387 + Alumni alumniSwati_387 = new Alumni("Swati Kumari", "Electrical Engineering", "2016", "Data Scientist", "Infosys", + new ArrayList<>(Arrays.asList("data analytics", "machine learning", "Python")), "Swati_387", "swati@example.com", "4567890123","Swati*987"); + + Post postSwati387 = new Post("Swati_1", "Mastering Web Development", "2023-04-10", "2023-04-15", "2023-04-16", + "Dive deep into the world of web development and master HTML, CSS, and JavaScript. Join us on this coding journey!", + new ArrayList<>(Arrays.asList("#nodejs", "#angularjs", "#web"))); + + alumniSwati_387.posts.add(postSwati387); + alumniMap.put("Swati_387", alumniSwati_387); + + // Komal_399 + Alumni alumniKomal_399 = new Alumni("Komal Patel", "Information Technology", "2020", "Frontend Developer", "Tech Mahindra", + new ArrayList<>(Arrays.asList("web design", "CSS", "JavaScript")), "Komal_399", "komal@example.com", "6789012345","Ko@456mal"); + + Post postKomal399 = new Post("Komal_1", "Internship Guidance in Web Development", "2023-04-10", "2023-04-15", "2023-04-16", + "Looking for internship opportunities in web development? Dive deep into HTML, CSS, and JavaScript skills. Join us for guidance and tips!", + new ArrayList<>(Arrays.asList("#internship", "#webdevelopment", "#guidance"))); + + alumniKomal_399.posts.add(postKomal399); + + Registration r25=new Registration("BCD9012345", "Sonal Gupta", "9876543462", "sonal@xyzcollege.in"); + + Registration r26=new Registration("YZA8901234", "Amit Jain", "9876543461", "amit@xyzcollege.in"); + + Registration r27=new Registration("EFG0123456", "Aarav Sharma", "9876543463", "aarav@xyzcollege.in"); + + Registration r28=new Registration("HIJ1234567", "Kavya Reddy", "9876543464", "kavya@xyzcollege.in"); + + postKomal399.registeredStudents.add(r25); + + postKomal399.registeredStudents.add(r26); + + postKomal399.registeredStudents.add(r27); + + postKomal399.registeredStudents.add(r28); + + alumniMap.put("Komal_399", alumniKomal_399); + + // Natasha_908 + Alumni alumniNatasha_908 = new Alumni("Natasha Singh", "Mechanical Engineering", "2013", "Engineering Manager", "Wipro", + new ArrayList<>(Arrays.asList("project management", "team leadership")), "Natasha_908", "natasha@example.com", "5678901234","Natasha@678#"); + + Post postNatasha908 = new Post("Natasha_1", "Navigating Engineering Management", "2023-04-10", "2023-04-15", "2023-04-16", + "Explore the world of engineering management and learn effective project management and team leadership skills. Join us for insights and guidance!", + new ArrayList<>(Arrays.asList("#engineeringmanagement", "#projectmanagement", "#teamleadership"))); + + //for postNatasha908 + + + + Registration r17=new Registration("BCD9012345", "Sonal Gupta", "9876543462", "sonal@xyzcollege.in"); + + Registration r18=new Registration("YZA8901234", "Amit Jain", "9876543461", "amit@xyzcollege.in"); + + Registration r19=new Registration("EFG0123456", "Aarav Sharma", "9876543463", "aarav@xyzcollege.in"); + + Registration r20=new Registration("DEF2345678", "Rohan Desh", "9876543211", "rohan@xyzcollege.in"); + + + + postNatasha908.registeredStudents.add(r17); + + postNatasha908.registeredStudents.add(r18); + + postNatasha908.registeredStudents.add(r19); + + postNatasha908.registeredStudents.add(r20); + + alumniNatasha_908.posts.add(postNatasha908); + alumniMap.put("Natasha_908", alumniNatasha_908); + + // Nisha_103 + Alumni alumniNisha_103 = new Alumni("Nisha Sharma", "Computer Science", "2014", "AI Researcher", "Tech Mahindra", + new ArrayList<>(Arrays.asList("artificial intelligence", "research", "Python")), "Nisha_103", "nisha@example.com", "7890123456","Nisha#234"); + + Post postNisha103_1 = new Post("Nisha_1", "AI Research Symposium", "2023-03-15", "2023-03-20", "2023-03-25", + "Join us for an AI research symposium featuring talks from leading experts and hands-on workshops in Python and machine learning.", + new ArrayList<>(Arrays.asList("#AIresearch", "#Python", "#machinelearning"))); + + //for post4 + + Registration r13=new Registration("PQR5678901", "Priya Gupta", "9876543458", "priya@xyzcollege.in"); + + Registration r14=new Registration("YZA8901234", "Amit Jain", "9876543461", "amit@xyzcollege.in"); + + Registration r15=new Registration("ABC1234567", "Riddhi Sharma", "9876543210", "riddhi@xyzcollege.in"); + + Registration r16=new Registration("DEF2345678", "Rohan Desh", "9876543211", "rohan@xyzcollege.in"); + + + + postNisha103_1.registeredStudents.add(r13); + + postNisha103_1.registeredStudents.add(r14); + + postNisha103_1.registeredStudents.add(r15); + + postNisha103_1.registeredStudents.add(r16); + + + + alumniNisha_103.posts.add(postNisha103_1); + + // Add Nisha_103 to alumniMap + alumniMap.put("Nisha_103", alumniNisha_103); + + // Rhea_172 + Alumni alumniRhea_172 = new Alumni("Rhea Gupta", "Electrical Engineering", "2019", "Business Analyst", "Capgemini", + new ArrayList<>(Arrays.asList("business analysis", "requirements gathering")), "Rhea_172", "rhea@example.com", "8901234567","Rhea*$345"); + + Post postRhea172_1 = new Post("Rhea_1", "Business Analysis Workshop", "2023-04-05", "2023-04-10", "2023-04-15", + "Enhance your business analysis skills with our comprehensive workshop covering industry best practices and tools.", + new ArrayList<>(Arrays.asList("#businessanalysis", "#workshop", "#careerdevelopment"))); + + // registrations for postRhea172_1 + + Registration r21=new Registration("BCD9012345", "Sonal Gupta", "9876543462", "sonal@xyzcollege.in"); + + Registration r22=new Registration("YZA8901234", "Amit Jain", "9876543461", "amit@xyzcollege.in"); + + Registration r23=new Registration("EFG0123456", "Aarav Sharma", "9876543463", "aarav@xyzcollege.in"); + + Registration r24=new Registration("HIJ1234567", "Kavya Reddy", "9876543464", "kavya@xyzcollege.in"); + + + + postRhea172_1.registeredStudents.add(r21); + + postRhea172_1.registeredStudents.add(r22); + + postRhea172_1.registeredStudents.add(r23); + + postRhea172_1.registeredStudents.add(r24); + + alumniRhea_172.posts.add(postRhea172_1); + + // Add Rhea_172 to alumniMap + alumniMap.put("Rhea_172", alumniRhea_172); + + // Simran_283 + Alumni alumniSimran_283 = new Alumni("Simran Singh", "Mechanical Engineering", "2015", "Product Designer", "HCL Technologies", + new ArrayList<>(Arrays.asList("product design", "CAD", "prototyping")), "Simran_283", "simran@example.com", "9012345678","Simran#234@"); + + Post postSimran283_1 = new Post("Simran_1", "Prototyping Workshop", "2023-05-10", "2023-05-15", "2023-05-20", + "Join our prototyping workshop to learn about CAD tools and techniques for creating innovative product designs.", + new ArrayList<>(Arrays.asList("#prototyping", "#workshop", "#CAD"))); + + alumniSimran_283.posts.add(postSimran283_1); + + // Add Simran_283 to alumniMap + alumniMap.put("Simran_283", alumniSimran_283); + + // Muskaan_283 + Alumni alumniMuskaan_283 = new Alumni("Muskaan Verma", "Information Technology", "2018", "UX Designer", "L&T Infotech", + new ArrayList<>(Arrays.asList("user experience", "UI design", "wireframing")), "Muskaan_283", "muskaan@example.com", "0123456789","Muska@n456"); + + Post postMuskaan283_1 = new Post("Muskaan_1", "UI Design Workshop", "2023-06-05", "2023-06-10", "2023-06-15", + "Learn the principles of effective UI design and wireframing in our hands-on workshop led by industry experts.", + new ArrayList<>(Arrays.asList("#UIDesign", "#workshop", "#UX"))); + + + + alumniMuskaan_283.posts.add(postMuskaan283_1); + + // Add Muskaan_283 to alumniMap + alumniMap.put("Muskaan_283", alumniMuskaan_283); + + + + a.initializeTree(); + System.out.println(a.data); + for(String alumniK : alumniMap.keySet()) { + + Alumni currAlumni = alumniMap.get(alumniK); + a.addBranch(currAlumni.branch, alumniK); + a.addPassingYear(currAlumni.passingYear, alumniK); + a.addDomain(currAlumni.domain, alumniK); + a.addOrganisation(currAlumni.organisation, alumniK); + + + } +} +void display(AlumniTree root) { + if (root == null) + return; + + System.out.println(root.data); + LinkedList child = root.child; + if (child != null) { + for (AlumniTree tmp : child) + display(tmp); + } + +} + +static LinkedList seeAlumniByBranch(AlumniTree root) { + + LinkedList child = root.child; + + for (AlumniTree curr : child) { + if (curr.data == "Branch") { + return curr.child; + } + } + return null; + +} + +static LinkedList seeAlumniByDomain(AlumniTree root) { + + LinkedList child = root.child; + + for (AlumniTree curr : child) { + if (curr.data == "Domain") { + return curr.child; + } + } + return null; + +} + +void printAllPosts() { + for (Alumni alumni : alumniMap.values()) { + for (Post post : alumni.getPosts()) { + if (alumni.getPosts() != null) { + System.out.println("Alumni Name: " + alumni.name); + System.out.println("Posts:"); + + System.out.println("Post ID: " + post.getId()); + System.out.println("Title: " + post.getTitle()); + System.out.println("Date of Event: " + post.getPostDate()); + System.out.println("Deadline of registration: " + post.getDeadlineOfRegistration()); + System.out.println("Description: " + post.getPostDescription()); + System.out.println("Tags: " + post.getTags()); + System.out.println("-----------------------------"); + } + } + } +} + +static LinkedList seeAlumniByOrganisation(AlumniTree root) { + + LinkedList child = root.child; + + for (AlumniTree curr : child) { + if (curr.data == "Organisation") { + return curr.child; + } + } + return null; + +} + +static LinkedList seeAlumniByPassingYear(AlumniTree root) { + + LinkedList child = root.child; + + for (AlumniTree curr : child) { + if (curr.data == "Passing Year") { + return curr.child; + } + } + return null; +} +//add in AlumniDB and remove earlier method from alumni + + + + + +public void createPost(String alId) { + +Scanner input = new Scanner(System.in); + +System.out.print("Enter post ID: "); + +String postId = input.nextLine(); + +System.out.print("Enter post title: "); + +String postTitle = input.nextLine(); + +System.out.print("Enter post date (yyyy-mm-dd): "); + +String postDate = input.nextLine(); + +System.out.print("Enter deadline of registration: "); + +String deadlineOfRegistration = input.nextLine(); + +System.out.print("Enter date of event (yyyy-mm-dd): "); + +String dateOfEvent = input.nextLine(); + +System.out.print("Enter post description: "); + +String postDescription = input.nextLine(); + +System.out.print("Enter tags : "); + +String[] tagArray = input.nextLine().split(","); + +ArrayList postTags = new ArrayList<>(Arrays.asList(tagArray)); + +// Create the new post + +Post newPost = new Post(postId, postTitle, postDate, deadlineOfRegistration, dateOfEvent, postDescription, postTags); + +// Update the database with the new post + +if (AlumniDB.alumniMap.containsKey(alId)) { + +Alumni alumni = AlumniDB.alumniMap.get(alId); + +alumni.posts.add(newPost); + +alumniMap.put(alId,alumni); + +System.out.println("Post added to the database successfully!"); + +} else { + +System.out.println("Alumni with ID " + alId + " not found."); + +} + +System.out.println("Post created successfully!"); + +} + + + +void createNewAlumni() { + + Scanner scanner = new Scanner(System.in); + + HashMap alumniMap = new HashMap<>(); + + System.out.println("Enter alumni details:"); + + System.out.print("Name: "); + + String name = scanner.nextLine(); + + System.out.print("Branch: "); + + String branch = scanner.nextLine(); + + System.out.print("Passing Year: "); + + String passingYear = scanner.next(); + + scanner.nextLine(); + + System.out.print("Job Profile: "); + + String jobProfile = scanner.nextLine(); + + System.out.print("Tags (comma-separated): "); + + String tagsInput = scanner.nextLine(); + + ArrayList tags = new ArrayList<>(Arrays.asList(tagsInput.split(", "))); + + System.out.print("ID: "); + + String id = scanner.nextLine(); + + System.out.print("Gmail: "); + + String gmail = scanner.nextLine(); + + System.out.print("Contact: "); + + String contact = scanner.nextLine(); + + System.out.print("Password : "); + + String p = scanner.nextLine(); + + alumniMap.put(id, new Alumni(name, branch, passingYear, jobProfile, "default", tags, id, gmail, contact,p)); + +} + +public void seeAllAlumni() { + for (String id : alumniMap.keySet()) { + displayAlumniDetailsById(id); + } +} + +boolean checkAlumni(String alId, String alPass) { + if(alumniMap.containsKey(alId)) { + Alumni a= alumniMap.get(alId); + if(a.password.equals(alPass)) return true; + else System.out.println("Incorrect Password!"); + } + return false; +} +public void displayAlumniDetailsByIdInDetails(String id) { + + if (alumniMap.containsKey(id)) { + + Alumni alumni = alumniMap.get(id); + + + System.out.println("-------------------------------------"); + + System.out.println("Id : " + alumni.id); + + System.out.println("Name : " + alumni.name); + + System.out.println("Branch : " + alumni.branch); + + System.out.println("Passing Year: " + alumni.passingYear); + + System.out.println("Job Profile : " + alumni.domain); + + System.out.println("Organisation: " + alumni.organisation); + + System.out.println("Tags : " + alumni.tags); + + System.out.println("Gmail : " + alumni.gmail); + + System.out.println("Contact : " + alumni.contact); + + + + + + for (Post post : alumni.getPosts()) { + + if (alumni.getPosts() != null) { + + + + System.out.println("Posts:"); + + + + System.out.println("Post ID: " + post.getId()); + + System.out.println("Title: " + post.getTitle()); + + System.out.println("Date of Event: " + post.getPostDate()); + + System.out.println("Deadline of registration: " + post.getDeadlineOfRegistration()); + + System.out.println("Description: " + post.getPostDescription()); + + System.out.println("Tags: " + post.getTags()); + + System.out.println("-----------------------------"); + + } + + } + + + + System.out.println("-------------------------------------"); + + + + } else { + + System.out.println("Alumni with ID " + id + " not found."); + + } + +} + +public void displayAlumniDetailsById(String id) { + if (alumniMap.containsKey(id)) { + Alumni alumni = alumniMap.get(id); + + System.out.println("-------------------------------------"); + System.out.println("Id : " + alumni.id); + System.out.println("Name : " + alumni.name); + System.out.println("Branch : " + alumni.branch); + System.out.println("Passing Year: " + alumni.passingYear); + System.out.println("Job Profile : " + alumni.domain); + System.out.println("-------------------------------------"); + } else { + System.out.println("Alumni with ID " + id + " not found."); + } +} + + public void deleteAlumniDetailsById(String id) { + + if (alumniMap.containsKey(id)){ + + + + Alumni alumni = alumniMap.get(id); + + a.deleteBranch(alumni.branch,alumni.name); + + a.deleteDomain(alumni.domain,alumni.name); + + a.deleteOrganisation(alumni.organisation,alumni.name); + + a.deletePassingYear(alumni.passingYear,alumni.name); + + alumni.posts=null; + + alumniMap.remove(id); + + + + }} + + public void updateAlumniDetails(String alumniId) { + Scanner scanner = new Scanner(System.in); + + if (alumniMap.containsKey(alumniId)) { + Alumni alumni = alumniMap.get(alumniId); + + System.out.println("Enter updated details for alumni " + alumniId + ":"); + + System.out.print("Name: "); + String name = scanner.nextLine(); + + System.out.print("Branch: "); + String branch = scanner.nextLine(); + + System.out.print("Passing Year: "); + String passingYear = scanner.nextLine(); + + System.out.print("Job Profile: "); + String jobProfile = scanner.nextLine(); + + System.out.print("Organisation: "); + String organisation = scanner.nextLine(); + + System.out.print("Tags (comma-separated): "); + String tagsInput = scanner.nextLine(); + ArrayList tags = new ArrayList<>(Arrays.asList(tagsInput.split(","))); + + + System.out.print("Gmail: "); + String gmail = scanner.nextLine(); + + System.out.print("Contact: "); + String contact = scanner.nextLine(); + + // Update alumni details + alumni.name=name; + alumni.branch= branch; + alumni.passingYear=passingYear; + alumni.domain =jobProfile; + alumni.organisation=organisation; + alumni.tags=tags; + alumni.gmail=gmail; + alumni.contact=contact; + + // Put the updated alumni back into the map + alumniMap.put(alumniId, alumni); + System.out.println("Alumni details updated successfully!"); + } else { + System.out.println("Alumni with ID " + alumniId + " not found."); + } + } +} diff --git a/Team 31 - Cummins Connect/AlumniTree.java b/Team 31 - Cummins Connect/AlumniTree.java new file mode 100644 index 0000000..79a59e3 --- /dev/null +++ b/Team 31 - Cummins Connect/AlumniTree.java @@ -0,0 +1,427 @@ +package buffer; + +import java.util.LinkedList; + +class AlumniTree { + + String data; + LinkedList child; + static AlumniTree root; + + AlumniTree(String data) { + + this.data = data; + this.child = new LinkedList<>(); + + } + + void initializeTree() { + + root = new AlumniTree("Alumni Tree"); + root.child.add(new AlumniTree("Passing Year")); + root.child.add(new AlumniTree("Domain")); + root.child.add(new AlumniTree("Branch")); + root.child.add(new AlumniTree("Organisation")); + + } + + static void addDomain(String Domain, String Uname) { + + AlumniTree newAlumni = new AlumniTree( Uname ); + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + + for (AlumniTree at : temp){ + if (at.data.equals("Domain")) { + curr = at; + } + } + AlumniTree par = curr; + child = curr.child; + temp = child; + curr = null; + boolean isFound = false; + + for (AlumniTree at : temp){ + if (at.data.equals(Domain)){ + isFound = true; + curr = at; + } + } + if (isFound) { + curr.child.add(newAlumni); + } else { + AlumniTree newYear = new AlumniTree(Domain); + newYear.child.add(newAlumni); + par.child.add(newYear); + } + } + static void addBranch(String Branch, String Uname){ + + AlumniTree newAlumni = new AlumniTree(Uname); + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + for (AlumniTree at : temp) { + if (at.data.equals("Branch")) { + curr = at; + } + } + AlumniTree par = curr; + child = curr.child; + temp = child; + curr = null; + boolean isFound = false; + + for (AlumniTree at : temp) { + if (at.data.equals(Branch)) { + isFound = true; + curr = at; + } + } + if (isFound) { + curr.child.add(newAlumni); + } else { + AlumniTree newYear = new AlumniTree(Branch); + newYear.child.add(newAlumni); + par.child.add(newYear); + } + } + static void addPassingYear(String passYear, String Uname){ + + AlumniTree newAlumni = new AlumniTree(Uname); + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + for (AlumniTree at : temp) { + if (at.data.equals("Passing Year")) { + curr = at; + } + } + AlumniTree par = curr; + child = curr.child; + temp = child; + curr = null; + boolean isFound = false; + + for (AlumniTree at : temp) { + if (at.data.equals(passYear)) { + isFound = true; + curr = at; + } + } + if (isFound) { + curr.child.add(newAlumni); + } else { + AlumniTree newYear = new AlumniTree(passYear); + newYear.child.add(newAlumni); + par.child.add(newYear); + } + } + void addOrganisation(String Organisation, String Uname){ + + AlumniTree newAlumni = new AlumniTree(Uname); + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + for (AlumniTree at : temp) { + if (at.data.equals("Organisation")) { + curr = at; + } + } + AlumniTree par = curr; + child = curr.child; + temp = child; + curr = null; + boolean isFound = false; + + for (AlumniTree at : temp) { + if (at.data.equals(Organisation)) { + isFound = true; + curr = at; + } + } + if (isFound) { + curr.child.add(newAlumni); + } else { + AlumniTree newYear = new AlumniTree(Organisation); + newYear.child.add(newAlumni); + par.child.add(newYear); + } + } + void deleteOrganisation(String Organisation, String Uname){ + + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + for (AlumniTree at : temp){ + if (at.data.equals("Organisation")) { + curr = at; + } + } + AlumniTree par = curr; + + child = curr.child; + + temp = child; + + curr = null; + + boolean isFound = false; + + for (AlumniTree at : temp){ + + if (at.data.equals(Organisation)){ + + isFound = true; + + curr = at; + } + } + if (isFound) { + + for(AlumniTree ct:curr.child){ + + if(ct.data.equals(Uname)){ + + curr.child.remove(ct); + + } + } + } else { + + System.out.println("Alumni does not exist"); + return; + } + + if(curr.child==null){ + + curr=null; + } + + } + + void deletePassingYear(String passYear, String Uname) + + { + + LinkedList child = root.child; + + LinkedList temp = child; + + AlumniTree curr = null; + + + + for (AlumniTree at : temp){ + + if (at.data.equals("Passing Year")) { + + curr = at; + + } + + } + + + + AlumniTree par = curr; + + child = curr.child; + + temp = child; + + curr = null; + + boolean isFound = false; + + for (AlumniTree at : temp){ + + if (at.data.equals(passYear)){ + + isFound = true; + + curr = at; + + } + + } + + + + if (isFound) { + + + + for(AlumniTree ct:curr.child) + + { + + if(ct.data.equals(Uname)) + + { + + curr.child.remove(ct); + + + + } + + + + } + + } else { + + System.out.println("Alumni does not exist"); + + return; + + } + + + + if(curr.child==null) + { + + curr=null; + } + + } + void deleteBranch(String Branch, String Uname) + + { + + LinkedList child = root.child; + + LinkedList temp = child; + + AlumniTree curr = null; + for (AlumniTree at : temp){ + if (at.data.equals("Branch")) { + curr = at; + } + } + AlumniTree par = curr; + + child = curr.child; + + temp = child; + + curr = null; + + boolean isFound = false; + + for (AlumniTree at : temp){ + + if (at.data.equals(Branch)){ + + isFound = true; + + curr = at; + break; + } + } + + if (isFound) { + + for(AlumniTree ct:curr.child){ + + if(ct.data.equals(Uname)){ + + curr.child.remove(ct); + + break; + } + } + } else { + System.out.println("Alumni does not exist"); + + return; + } + if(curr.child==null) + { + curr=null; + } + } + void deleteDomain(String Domain, String Uname) + + { + + LinkedList child = root.child; + LinkedList temp = child; + AlumniTree curr = null; + + for (AlumniTree at : temp){ + + if (at.data.equals("Domain")) { + + curr = at; + + + + } + + } + + + + AlumniTree par = curr; + + child = curr.child; + + temp = child; + + curr = null; + + boolean isFound = false; + + for (AlumniTree at : temp){ + + if (at.data.equals(Domain)){ + + isFound = true; + + curr = at; + + } + + } + + if (isFound) { + + for(AlumniTree ct:curr.child) + + { + + if(ct.data.equals(Uname)) + + { + + curr.child.remove(ct); + + } + } + + } else { + + System.out.println("Alumni does not exist"); + + return; + } + + if(curr.child==null) + + { + + curr=null; + + } + + + + } + +} + diff --git a/Team 31 - Cummins Connect/CumminsImage.png b/Team 31 - Cummins Connect/CumminsImage.png new file mode 100644 index 0000000..0c6e42e Binary files /dev/null and b/Team 31 - Cummins Connect/CumminsImage.png differ diff --git a/Team 31 - Cummins Connect/Main.java b/Team 31 - Cummins Connect/Main.java new file mode 100644 index 0000000..1ae92bf --- /dev/null +++ b/Team 31 - Cummins Connect/Main.java @@ -0,0 +1,2117 @@ +package buffer; + + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import java.awt.event.*; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import java.awt.geom.RoundRectangle2D; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; + +public class Main extends JFrame { + + private static JPanel mainPanel; + private JButton[] optionButtons; + private AlumniDB alumniDB; + private AlumniTree alumniTree; + private StudentDB studentDB; + + private boolean loggedIn = false; + + private void seeAlumniByPreference(int ch,String name) { + + switch (ch) { + case 1: + LinkedList almns = AlumniDB.seeAlumniByBranch(AlumniDB.a.root); + displayPreferenceChoices(almns,name); + break; + case 2: + almns = AlumniDB.seeAlumniByPassingYear(AlumniDB.a.root); + displayPreferenceChoices(almns,name); + break; + case 3: + almns = AlumniDB.seeAlumniByDomain(AlumniDB.a.root); + displayPreferenceChoices(almns,name); + break; + case 4: + + almns = AlumniDB.seeAlumniByOrganisation(AlumniDB.a.root); + displayPreferenceChoices(almns,name); + break; + } + } + + public Main() { + + setTitle("Alumni and Student Management System"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setExtendedState(JFrame.MAXIMIZED_BOTH); + + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayout(0, 1)); + add(mainPanel); + + alumniDB = new AlumniDB(); + studentDB = new StudentDB(); + alumniTree = new AlumniTree(""); + optionButtons = new JButton[5]; + + + + displayMainMenu(); + + } + private void displayMainMenu() { + mainPanel.removeAll(); + + JPanel backgroundPanel = new JPanel() { + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + ImageIcon backgroundImage = new ImageIcon("C:\\Users\\Sweta Thakre\\Desktop\\Buffer\\Buffer\\src\\buffer\\CumminsImage.jpg"); + g.drawImage(backgroundImage.getImage(), 0, 0,getWidth(), getHeight(), this); + g.setColor(new Color(255, 255, 255, 190)); + g.fillRect(0, 0, getWidth(), getHeight()); } + }; + backgroundPanel.setLayout(new BoxLayout(backgroundPanel, BoxLayout.Y_AXIS)); + + JLabel headingLabel = new JLabel("Cummins Connect"); + headingLabel.setFont(new Font("Monotype Corsiva", Font.BOLD, 56)); + headingLabel.setForeground(Color.BLACK); + headingLabel.setAlignmentX(Component.CENTER_ALIGNMENT); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setOpaque(false); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS)); + buttonPanel.setAlignmentX(Component.CENTER_ALIGNMENT); + + // Creating buttons for Alumni and Student options + JButton alumniButton = new JButton("Alumni"); + setupButton(alumniButton); + alumniButton.addActionListener(e -> displayAlumniOptions()); + buttonPanel.add(alumniButton); + + buttonPanel.add(Box.createVerticalStrut(20)); + + JButton studentButton = new JButton("Student"); + setupButton(studentButton); + studentButton.addActionListener(e -> { + + displayStudentLoginPage(); + + }); + buttonPanel.add(studentButton); + + backgroundPanel.add(Box.createVerticalGlue()); + backgroundPanel.add(headingLabel); + backgroundPanel.add(Box.createVerticalStrut(20)); + backgroundPanel.add(buttonPanel); + backgroundPanel.add(Box.createVerticalGlue()); + + backgroundPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5, true)); + backgroundPanel.setMinimumSize(new Dimension(800, 600)); + + mainPanel.add(backgroundPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void setupButton(JButton button) { + button.setBackground(Color.BLACK); + button.setForeground(Color.WHITE); + button.setFont(button.getFont().deriveFont(Font.PLAIN, 14)); + button.setMaximumSize(new Dimension(150, 30)); + button.setAlignmentX(Component.CENTER_ALIGNMENT); + } + private void handleAlumniSignUp() { + mainPanel.removeAll(); + + JPanel signupFormPanel = new JPanel(new GridBagLayout()); + signupFormPanel.setBackground(Color.WHITE); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.WEST; + + // Adding form fields + JLabel nameLabel = new JLabel("Name:"); + signupFormPanel.add(nameLabel, gbc); + gbc.gridx++; + JTextField nameField = new JTextField(20); + signupFormPanel.add(nameField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel branchLabel = new JLabel("Branch:"); + signupFormPanel.add(branchLabel, gbc); + gbc.gridx++; + JComboBox branchDropdown = new JComboBox<>(new String[]{"Electrical Engineering", "Information Technology", "Mechanical Engineering", "Computer Science"}); + signupFormPanel.add(branchDropdown, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel passingYearLabel = new JLabel("Passing Year:"); + signupFormPanel.add(passingYearLabel, gbc); + gbc.gridx++; + int currentYear = Calendar.getInstance().get(Calendar.YEAR); + Integer[] years = new Integer[currentYear - 1989]; + for (int i = 1990; i <= currentYear; i++) { + years[i - 1990] = i; + } + JComboBox passingYearDropdown = new JComboBox<>(years); + signupFormPanel.add(passingYearDropdown, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel domainLabel = new JLabel("Domain:"); + signupFormPanel.add(domainLabel, gbc); + gbc.gridx++; + JTextField domainField = new JTextField(20); + signupFormPanel.add(domainField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel passwordLabel = new JLabel("Password:"); + signupFormPanel.add(passwordLabel, gbc); + gbc.gridx++; + JPasswordField passwordField = new JPasswordField(20); + signupFormPanel.add(passwordField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel organisationLabel = new JLabel("Organisation:"); + signupFormPanel.add(organisationLabel, gbc); + gbc.gridx++; + JTextField organisationField = new JTextField(20); + signupFormPanel.add(organisationField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel tagsLabel = new JLabel("Tags:"); + signupFormPanel.add(tagsLabel, gbc); + gbc.gridx++; + JTextField tagsField = new JTextField(20); + signupFormPanel.add(tagsField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel idLabel = new JLabel("ID:"); + signupFormPanel.add(idLabel, gbc); + gbc.gridx++; + JTextField idField = new JTextField(20); + signupFormPanel.add(idField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel gmailLabel = new JLabel("Gmail:"); + signupFormPanel.add(gmailLabel, gbc); + gbc.gridx++; + JTextField gmailField = new JTextField(20); + signupFormPanel.add(gmailField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel contactLabel = new JLabel("Contact:"); + signupFormPanel.add(contactLabel, gbc); + gbc.gridx++; + JTextField contactField = new JTextField(20); + signupFormPanel.add(contactField, gbc); + + gbc.gridy++; + gbc.gridx = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + JButton submitButton = new JButton("Submit"); + submitButton.setBackground(Color.GREEN); + submitButton.setForeground(Color.BLACK); + submitButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + submitButton.setFocusPainted(false); + submitButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String name = nameField.getText(); + String branch = (String) branchDropdown.getSelectedItem(); + Integer passingYear = (int)passingYearDropdown.getSelectedItem(); + String domain = domainField.getText(); + String password = new String(passwordField.getPassword()); + String organisation = organisationField.getText(); + String id = idField.getText(); + String gmail = gmailField.getText(); + String contact = contactField.getText(); + String tagsString = tagsField.getText(); + ArrayList tags = new ArrayList<>(Arrays.asList(tagsString.split("\\s*,\\s*"))); + + // Validate input... + if (name.isEmpty() || branch.isEmpty() ||domain.isEmpty() || + password.isEmpty() || organisation.isEmpty() || tags.isEmpty() || id.isEmpty() || + gmail.isEmpty() || contact.isEmpty()) { + + JOptionPane.showMessageDialog(mainPanel, "Please fill in all required fields.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + if(alumniDB.alumniMap.containsKey(id)) { + JOptionPane.showMessageDialog(mainPanel, "Username Alreaady Registered!."); + return ; + } + if(alumniDB.alumniMap.containsKey(gmail)) { + JOptionPane.showMessageDialog(mainPanel, "E-mail Id Alreaady Registered!."); + return ; + } + + + alumniDB.alumniMap.put(id,new Alumni( name,branch ,passingYear.toString(),domain,organisation,new ArrayList<>(),id,gmail,contact,password)); + + alumniTree.addDomain(id,domain); + alumniTree.addOrganisation(id,domain); + alumniTree.addPassingYear(id,passingYear.toString()); + alumniTree.addBranch(id,branch); + + JOptionPane.showMessageDialog(mainPanel, "Account successfully created!", "Success", JOptionPane.INFORMATION_MESSAGE); + displayAlumniOptions(); + } + }); + + signupFormPanel.add(submitButton, gbc); + + gbc.gridy++; + JButton cancelButton = new JButton("Cancel"); + cancelButton.setBackground(Color.GRAY); + cancelButton.setForeground(Color.WHITE); + cancelButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + cancelButton.setFocusPainted(false); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + displayAlumniOptions(); // Go back to the signup/login options + } + }); + signupFormPanel.add(cancelButton, gbc); + + // Add signup form panel to main panel + mainPanel.add(signupFormPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void handleStudentSignup() { + mainPanel.removeAll(); + + JPanel signupFormPanel = new JPanel(new GridBagLayout()); + signupFormPanel.setBackground(Color.WHITE); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.WEST; + + JLabel rollNumLabel = new JLabel("Roll Number:"); + signupFormPanel.add(rollNumLabel, gbc); + gbc.gridx++; + JTextField rollNumField = new JTextField(20); + signupFormPanel.add(rollNumField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel nameLabel = new JLabel("Name:"); + signupFormPanel.add(nameLabel, gbc); + gbc.gridx++; + JTextField nameField = new JTextField(20); + signupFormPanel.add(nameField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel contactNoLabel = new JLabel("Contact Number:"); + signupFormPanel.add(contactNoLabel, gbc); + gbc.gridx++; + JTextField contactNoField = new JTextField(20); + signupFormPanel.add(contactNoField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel emailLabel = new JLabel("Email:"); + signupFormPanel.add(emailLabel, gbc); + gbc.gridx++; + JTextField emailField = new JTextField(20); + signupFormPanel.add(emailField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel branchLabel = new JLabel("Branch:"); + signupFormPanel.add(branchLabel, gbc); + gbc.gridx++; + JTextField branchField = new JTextField(20); + signupFormPanel.add(branchField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel yearLabel = new JLabel("Year of Study:"); + signupFormPanel.add(yearLabel, gbc); + gbc.gridx++; + JTextField yearField = new JTextField(20); + signupFormPanel.add(yearField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel gpaLabel = new JLabel("GPA:"); + signupFormPanel.add(gpaLabel, gbc); + gbc.gridx++; + JTextField gpaField = new JTextField(20); + signupFormPanel.add(gpaField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel interestLabel = new JLabel("Area of Interest:"); + signupFormPanel.add(interestLabel, gbc); + gbc.gridx++; + JTextField interestField = new JTextField(20); + signupFormPanel.add(interestField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel workExpLabel = new JLabel("Work Experience:"); + signupFormPanel.add(workExpLabel, gbc); + gbc.gridx++; + JTextField workExpField = new JTextField(20); + signupFormPanel.add(workExpField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel passwordLabel = new JLabel("Password:"); + signupFormPanel.add(passwordLabel, gbc); + gbc.gridx++; + JPasswordField passwordField = new JPasswordField(20); + signupFormPanel.add(passwordField, gbc); + + gbc.gridy++; + gbc.gridx = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + JButton submitButton = new JButton("Submit"); + submitButton.setBackground(Color.GREEN); + submitButton.setForeground(Color.BLACK); + submitButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + submitButton.setFocusPainted(false); + submitButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String rollNum = rollNumField.getText(); + String name = nameField.getText(); + String contactNo = contactNoField.getText(); + String email = emailField.getText(); + String branch = branchField.getText(); + String yearOfStudyStr = yearField.getText(); + String gpaStr = gpaField.getText(); + String areaOfInterest = interestField.getText(); + String workExperience = workExpField.getText(); + String password = new String(passwordField.getPassword()); + + // Validate input... + if (rollNum.isEmpty() || name.isEmpty() || contactNo.isEmpty() || email.isEmpty() || + branch.isEmpty() || yearOfStudyStr.isEmpty() || gpaStr.isEmpty() || areaOfInterest.isEmpty() || + workExperience.isEmpty() || password.isEmpty()) { + JOptionPane.showMessageDialog(mainPanel, "Please fill in all required fields.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + + int yearOfStudy; + try { + yearOfStudy = Integer.parseInt(yearOfStudyStr); + if (yearOfStudy < 1 || yearOfStudy > 5) { + throw new NumberFormatException(); + } + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(mainPanel, "Please enter a valid year of study (1-5).", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + + double gpa; + try { + gpa = Double.parseDouble(gpaStr); + if (gpa < 0 || gpa > 10) { + throw new NumberFormatException(); + } + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(mainPanel, "Please enter a valid GPA between 0 and 10.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + + if (!isValidEmail(email)) { + JOptionPane.showMessageDialog(mainPanel, "Please enter a valid email address.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + StudentDB.studentsList.add(new Student(rollNum, name,contactNo, email, + branch, yearOfStudy, gpa,areaOfInterest ,workExperience ,password)); + System.out.println(StudentDB.studentsList.get(StudentDB.studentsList.size()-1).name+" "+StudentDB.studentsList.get(StudentDB.studentsList.size()-1).name ); + JOptionPane.showMessageDialog(mainPanel, "Account successfully created!", "Success", JOptionPane.INFORMATION_MESSAGE); + displayStudentLoginPage(); + } + }); + + signupFormPanel.add(submitButton, gbc); + + gbc.gridy++; + JButton cancelButton = new JButton("Cancel"); + cancelButton.setBackground(Color.GRAY); + cancelButton.setForeground(Color.WHITE); + cancelButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + cancelButton.setFocusPainted(false); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + displayStudentOptions(""); + } + }); + signupFormPanel.add(cancelButton, gbc); + + mainPanel.add(signupFormPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private boolean isValidEmail(String email) { + + return email.matches("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"); + } + private void displayAlumniOptions() { + mainPanel.removeAll(); + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(20, 20, 20, 20); + gbc.anchor = GridBagConstraints.CENTER; + + JLabel titleLabel = new JLabel("Alumni Options"); + titleLabel.setFont(new Font("Brush Script MT", Font.BOLD, 46)); + mainPanel.add(titleLabel, gbc); + + gbc.gridy++; + + String[] alumniOptions = {"Login", "Sign Up", "Back"}; + for (String option : alumniOptions) { + JButton button = new JButton(option); + button.setPreferredSize(new Dimension(200, 40)); + button.setFont(new Font("Palatino", Font.BOLD, 18)); + button.setBackground(new Color(41, 128, 185)); + button.setForeground(Color.WHITE); + button.setFocusPainted(false); + button.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + button.addActionListener(e -> { + switch (option) { + case "Login": + handleAlumniLogin(); + break; + case "Sign Up": + handleAlumniSignUp(); + break; + case "Back": + displayMainMenu(); + break; + } + }); + + gbc.gridy++; + mainPanel.add(button, gbc); + } + + // Add border to mainPanel + Border border = BorderFactory.createLineBorder(new Color(41, 128, 185), 2); + mainPanel.setBorder(border); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void displayStudentLoginPage() { + mainPanel.removeAll(); + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(20, 20, 20, 20); + gbc.anchor = GridBagConstraints.CENTER; + + JLabel titleLabel = new JLabel("Student Options"); + titleLabel.setFont(new Font("Brush Script MT", Font.BOLD, 35)); + mainPanel.add(titleLabel, gbc); + + gbc.gridy++; + + String[] alumniOptions = {"Login", "Sign Up", "Back"}; + for (String option : alumniOptions) { + JButton button = new JButton(option); + button.setPreferredSize(new Dimension(200, 40)); + button.setFont(new Font("Palatino", Font.BOLD, 18)); + button.setBackground(new Color(41, 128, 185)); + button.setForeground(Color.WHITE); + button.setFocusPainted(false); + button.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + button.addActionListener(e -> { + switch (option) { + case "Login": + handleStudentLogin(); + break; + case "Sign Up": + handleStudentSignup(); + break; + case "Back": + displayMainMenu(); + break; + } + }); + + gbc.gridy++; + mainPanel.add(button, gbc); + } + + // Add border to mainPanel + Border border = BorderFactory.createLineBorder(new Color(41, 128, 185), 2); + mainPanel.setBorder(border); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + static boolean checkStudent(String username, String password) { + for (Student s : StudentDB.studentsList) { + if (s.emailId.equals(username) && s.password.equals(password)) { + return true; + } + } + return false; + } + private void displayStudentOptions(String u_name) { + mainPanel.removeAll(); + + JPanel studentOptionsPanel = new JPanel(new GridBagLayout()); + studentOptionsPanel.setBackground(new Color(240, 240, 240)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.CENTER; + + JLabel titleLabel = new JLabel("Student Options"); + titleLabel.setForeground(new Color(9, 8, 20)); + titleLabel.setFont(new Font("Montserrat",Font.BOLD, 40)); + + studentOptionsPanel.add(titleLabel, gbc); + + gbc.gridy++; + + String[] studentOptions = {"See all alumni", "See alumni based on preference", "See alumni based on username", "See all posts", "Show Profile", "Back"}; + Dimension buttonSize = calculateButtonSize(studentOptions); + for (String option : studentOptions) { + JButton button = new JButton(option); + button.setPreferredSize(buttonSize); + button.setBackground(new Color(41, 128, 185)); + button.setForeground(Color.WHITE); + button.setFont(button.getFont().deriveFont(Font.BOLD, 16)); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(option.equals("Back")) + displayStudentLoginPage(); + else if(option.equals("Show Profile")) { + showProfile(u_name); + } + else + handleStudentOption(option,u_name); + } + }); + studentOptionsPanel.add(button, gbc); + gbc.gridy++; + } + + mainPanel.add(studentOptionsPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + private void showProfile(String emailId) { + Student student = null; + for (Student s : StudentDB.studentsList) { + if (s.emailId.equals(emailId)) { + student = s; + break; + } + } + + JFrame profileFrame = new JFrame("Student Profile"); + profileFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + profileFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + profileFrame.setUndecorated(true); + + JPanel profilePanel = new JPanel(new GridBagLayout()); + profilePanel.setBackground(new Color(240, 248, 255)); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(10, 10, 10, 10); + + JLabel profileHolderLabel = new JLabel(student.name); + Font profileHolderFont = new Font("Brush Script MT", Font.BOLD, 60); + profileHolderLabel.setFont(profileHolderFont); + profileHolderLabel.setForeground(new Color(47, 79, 79)); + + profilePanel.add(profileHolderLabel, gbc); + + gbc.gridy++; + gbc.anchor = GridBagConstraints.WEST; + Font labelFont = new Font("Arial", Font.PLAIN, 20); + JLabel nameLabel = new JLabel("Name:"); + nameLabel.setFont(labelFont); + JLabel nameValueLabel = new JLabel(student.name); + nameValueLabel.setFont(labelFont); + JLabel rollNumLabel = new JLabel("Roll Number:"); + rollNumLabel.setFont(labelFont); + JLabel rollNumValueLabel = new JLabel(student.rollNum); + rollNumValueLabel.setFont(labelFont); + JLabel contactNoLabel = new JLabel("Contact Number:"); + contactNoLabel.setFont(labelFont); + JLabel contactNoValueLabel = new JLabel(student.contactNo); + contactNoValueLabel.setFont(labelFont); + JLabel emailLabel = new JLabel("Email:"); + emailLabel.setFont(labelFont); + JLabel emailValueLabel = new JLabel(student.emailId); + emailValueLabel.setFont(labelFont); + JLabel passwordLabel = new JLabel("Password:"); + passwordLabel.setFont(labelFont); + JLabel passwordValueLabel = new JLabel(student.password); + passwordValueLabel.setFont(labelFont); + JLabel branchLabel = new JLabel("Branch:"); + branchLabel.setFont(labelFont); + JLabel branchValueLabel = new JLabel(student.branch); + branchValueLabel.setFont(labelFont); + JLabel yearOfStudyLabel = new JLabel("Year of Study:"); + yearOfStudyLabel.setFont(labelFont); + JLabel yearOfStudyValueLabel = new JLabel(String.valueOf(student.yearOfStudy)); + yearOfStudyValueLabel.setFont(labelFont); + JLabel GPALabel = new JLabel("GPA:"); + GPALabel.setFont(labelFont); + JLabel GPAValueLabel = new JLabel(String.valueOf(student.GPA)); + GPAValueLabel.setFont(labelFont); + JLabel areaOfInterestLabel = new JLabel("Area of Interest:"); + areaOfInterestLabel.setFont(labelFont); + JLabel areaOfInterestValueLabel = new JLabel(student.areaOfInterest); + areaOfInterestValueLabel.setFont(labelFont); + + profilePanel.add(nameLabel, gbc); + gbc.gridx++; + profilePanel.add(nameValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(rollNumLabel, gbc); + gbc.gridx++; + profilePanel.add(rollNumValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(contactNoLabel, gbc); + gbc.gridx++; + profilePanel.add(contactNoValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(emailLabel, gbc); + gbc.gridx++; + profilePanel.add(emailValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(passwordLabel, gbc); + gbc.gridx++; + profilePanel.add(passwordValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(branchLabel, gbc); + gbc.gridx++; + profilePanel.add(branchValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(yearOfStudyLabel, gbc); + gbc.gridx++; + profilePanel.add(yearOfStudyValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(GPALabel, gbc); + gbc.gridx++; + profilePanel.add(GPAValueLabel, gbc); + gbc.gridx = 0; + gbc.gridy++; + profilePanel.add(areaOfInterestLabel, gbc); + gbc.gridx++; + profilePanel.add(areaOfInterestValueLabel, gbc); + + JButton backButton = new JButton("Back"); + backButton.setFont(labelFont); + backButton.setPreferredSize(new Dimension(100, 40)); + backButton.setBackground(new Color(30, 144, 255)); + backButton.setForeground(Color.WHITE); + backButton.setFocusPainted(false); + backButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + displayStudentOptions(emailId); + profileFrame.dispose(); + + } + }); + + gbc.gridx = 0; + gbc.gridy++; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + profilePanel.add(backButton, gbc); + + profileFrame.add(profilePanel); + + profileFrame.setVisible(true); + } + private Dimension calculateButtonSize(String[] options) { + int maxWidth = 0; + int maxHeight = 0; + FontMetrics metrics = new JLabel().getFontMetrics(new JButton().getFont()); + + for (String option : options) { + int width = metrics.stringWidth(option); + int height = metrics.getHeight(); + maxWidth = Math.max(maxWidth, width); + maxHeight = Math.max(maxHeight, height); + } + + return new Dimension(350, maxHeight + 20); + } + + private void handlePostSignup(String u_name) { + mainPanel.removeAll(); + + JPanel postSignupFormPanel = new JPanel(new GridBagLayout()); + postSignupFormPanel.setBackground(new Color(255, 240, 245)); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.WEST; + + + JLabel alumniIdLabel = new JLabel("Alumni Id:"); + alumniIdLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(alumniIdLabel, gbc); + gbc.gridx++; + JTextField alumniIdField = new JTextField(20); + alumniIdField.setPreferredSize(new Dimension(200, 30)); + alumniIdField.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(alumniIdField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel idLabel = new JLabel("ID:"); + idLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(idLabel, gbc); + gbc.gridx++; + JTextField idField = new JTextField(20); + idField.setPreferredSize(new Dimension(200, 30)); + idField.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(idField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel titleLabel = new JLabel("Title:"); + titleLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(titleLabel, gbc); + gbc.gridx++; + JTextField titleField = new JTextField(20); + titleField.setPreferredSize(new Dimension(200, 30)); + titleField.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(titleField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel dateOfEventLabel = new JLabel("Date of Event:"); + dateOfEventLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(dateOfEventLabel, gbc); + gbc.gridx++; + JLabel yearLabel = new JLabel("(YYYY-MM-DD) Year:"); + yearLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(yearLabel, gbc); + gbc.gridx++; + + String[] years = {"2024", "2025", "2026", "2027", "2028", "2029", "2030"}; + JComboBox yearComboBox = new JComboBox<>(years); + yearComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(yearComboBox, gbc); + gbc.gridx++; + JLabel monthLabel = new JLabel("Month:"); + monthLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(monthLabel, gbc); + gbc.gridx++; + String[] months = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}; + JComboBox monthComboBox = new JComboBox<>(months); + monthComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(monthComboBox, gbc); + gbc.gridx++; + JLabel dayLabel = new JLabel("Day:"); + dayLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(dayLabel, gbc); + gbc.gridx++; + String[] days = new String[31]; + for (int i = 0; i < 31; i++) { + days[i] = String.format("%02d", i + 1); + } + JComboBox dayComboBox = new JComboBox<>(days); + dayComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(dayComboBox, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel deadlineLabel = new JLabel("Deadline of Registration:"); + deadlineLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineLabel, gbc); + gbc.gridx++; + JLabel deadlineYearLabel = new JLabel("(YYYY-MM-DD) Year:"); + deadlineYearLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineYearLabel, gbc); + gbc.gridx++; + + LocalDate currentDate = LocalDate.now(); + String[] deadlineYears = new String[7]; + for (int i = 0; i < 7; i++) { + deadlineYears[i] = String.valueOf(currentDate.getYear() + i); + } + JComboBox deadlineYearComboBox = new JComboBox<>(deadlineYears); + deadlineYearComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineYearComboBox, gbc); + gbc.gridx++; + JLabel deadlineMonthLabel = new JLabel("Month:"); + deadlineMonthLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineMonthLabel, gbc); + gbc.gridx++; + JComboBox deadlineMonthComboBox = new JComboBox<>(months); + deadlineMonthComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineMonthComboBox, gbc); + gbc.gridx++; + JLabel deadlineDayLabel = new JLabel("Day:"); + deadlineDayLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineDayLabel, gbc); + gbc.gridx++; + JComboBox deadlineDayComboBox = new JComboBox<>(days); + deadlineDayComboBox.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(deadlineDayComboBox, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel descriptionLabel = new JLabel("Post Description:"); + descriptionLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(descriptionLabel, gbc); + gbc.gridx++; + JTextField descriptionField = new JTextField(20); + descriptionField.setPreferredSize(new Dimension(200, 100)); + descriptionField.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(descriptionField, gbc); + + gbc.gridx = 0; + gbc.gridy++; + JLabel tagsLabel = new JLabel("Post Tags (comma-separated):"); + tagsLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(tagsLabel, gbc); + gbc.gridx++; + JTextField tagsField = new JTextField(20); + tagsField.setPreferredSize(new Dimension(200, 30)); + tagsField.setFont(new Font("Arial", Font.PLAIN, 16)); + postSignupFormPanel.add(tagsField, gbc); + + gbc.gridy++; + gbc.gridx = 0; + gbc.gridwidth = 4; + gbc.anchor = GridBagConstraints.CENTER; + JButton submitButton = new JButton("Submit"); + submitButton.setBackground(new Color(124, 252, 200)); + submitButton.setForeground(Color.WHITE); + submitButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + submitButton.setFocusPainted(false); + submitButton.setFont(new Font("Arial", Font.BOLD, 16)); + submitButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (idField.getText().isEmpty() || titleField.getText().isEmpty() || descriptionField.getText().isEmpty() || tagsField.getText().isEmpty()) { + JOptionPane.showMessageDialog(mainPanel, "Please fill in all the fields.", "Error", JOptionPane.ERROR_MESSAGE); + } + + else { + String id = idField.getText(); + String title = titleField.getText(); + String alumniId = alumniIdField.getText(); + String description = descriptionField.getText(); + String tagsInput = tagsField.getText(); + String[] tagsArray = tagsInput.split("\\s*,\\s*"); + ArrayList tagsList = new ArrayList<>(Arrays.asList(tagsArray)); + + String year = (String) yearComboBox.getSelectedItem(); + String month = (String) monthComboBox.getSelectedItem(); + String day = (String) dayComboBox.getSelectedItem(); + String deadlineYear = (String) deadlineYearComboBox.getSelectedItem(); + String deadlineMonth = (String) deadlineMonthComboBox.getSelectedItem(); + String deadlineDay = (String) deadlineDayComboBox.getSelectedItem(); + LocalDate currentDate = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String CurrentDate = currentDate.format(formatter); + + alumniDB.alumniMap.get(alumniId).posts.add(new Post(id,title,CurrentDate, (deadlineYear + "-" + deadlineMonth + "-" + deadlineDay),(year + "-" + month + "-" + day),description,tagsList)); + JOptionPane.showMessageDialog(mainPanel, "Posted Successfully !"); + showAlumniOptions(u_name); + + } + } + }); + postSignupFormPanel.add(submitButton, gbc); + + gbc.gridy++; + JButton cancelButton = new JButton("Cancel"); + cancelButton.setBackground(Color.GRAY); + cancelButton.setForeground(Color.WHITE); + cancelButton.setBorder(BorderFactory.createEmptyBorder(10, 25, 10, 25)); + cancelButton.setFocusPainted(false); + cancelButton.setFont(new Font("Arial", Font.BOLD, 16)); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showAlumniOptions(u_name); + } + }); + postSignupFormPanel.add(cancelButton, gbc); + + mainPanel.add(postSignupFormPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void showAlumniOptions(String u_name) { + mainPanel.removeAll(); + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(20, 20, 20, 20); + gbc.anchor = GridBagConstraints.CENTER; + + JLabel titleLabel = new JLabel("Alumni Options"); + titleLabel.setFont(new Font("Brush Script MT", Font.BOLD, 46)); + mainPanel.add(titleLabel, gbc); + + gbc.gridy++; + + String[] alumniOptions = {"Create a post", "Update Account", "Delete Account", "See Registrations", "Back"}; + for (String option : alumniOptions) { + JButton button = new JButton(option); + button.setPreferredSize(new Dimension(250, 40)); + button.setFont(new Font("Palatino", Font.BOLD, 18)); + button.setBackground(new Color(41, 128, 185)); + button.setForeground(Color.WHITE); + button.setFocusPainted(false); + button.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + button.addActionListener(e -> { + switch (option) { + case "Create a post": + handlePostSignup(u_name); + break; + case "Update Account": + handleUpdateAccount(alumniDB.alumniMap.get(u_name)); + break; + case "Delete Account": + String enteredUsername = JOptionPane.showInputDialog(mainPanel, "Enter Username:"); + String enteredPassword = JOptionPane.showInputDialog(mainPanel, "Enter Password:"); + + if (enteredUsername != null && enteredPassword != null) { + if (alumniDB.alumniMap.containsKey(u_name) && enteredUsername.equals(u_name) && enteredPassword.equals(alumniDB.alumniMap.get(u_name).password)) { + int deleteConfirmation = JOptionPane.showConfirmDialog(mainPanel, "Are you sure you want to delete your account?", "Confirmation", JOptionPane.YES_NO_OPTION); + if (deleteConfirmation == JOptionPane.YES_OPTION) { + Alumni a = alumniDB.alumniMap.get(u_name); + alumniTree.deleteDomain(a.domain,a.id); + alumniTree.deleteOrganisation(a.organisation,a.id); + alumniTree.deleteBranch(a.branch,a.id); + alumniTree.deletePassingYear(a.passingYear,a.id); + alumniDB.alumniMap.remove(u_name); + JOptionPane.showMessageDialog(mainPanel, "Alumni account deleted successfully!"); + displayAlumniOptions(); + } else { + JOptionPane.showMessageDialog(mainPanel, "Account deletion cancelled."); + showAlumniOptions(u_name); + } + } else { + JOptionPane.showMessageDialog(mainPanel, "Incorrect username or password. Please try again."); + } + } else { + JOptionPane.showMessageDialog(mainPanel, "Please enter both username and password."); + } + break; + case "See Registrations": + displayspecificPosts(u_name); + break; + case "Back": + displayAlumniOptions(); + break; + } + }); + + gbc.gridy++; + mainPanel.add(button, gbc); + } + + Border border = BorderFactory.createLineBorder(new Color(41, 128, 185), 2); + mainPanel.setBorder(border); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + private void handleUpdateAccount(Alumni alumniToUpdate) { + mainPanel.removeAll(); + mainPanel.setLayout(new GridBagLayout()); + + JPanel formPanel = new JPanel(new GridBagLayout()); + formPanel.setBackground(new Color(255, 240, 245)); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.WEST; + + JLabel nameLabel = new JLabel("Name:"); + nameLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + formPanel.add(nameLabel, gbc); + + JTextField nameField = new JTextField(alumniToUpdate.name, 20); + nameField.setPreferredSize(new Dimension(200, 30)); + nameField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(nameField, gbc); + + JLabel domainLabel = new JLabel("Domain:"); + domainLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 1; + formPanel.add(domainLabel, gbc); + + JTextField domainField = new JTextField(alumniToUpdate.domain, 20); + domainField.setPreferredSize(new Dimension(200, 30)); + domainField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(domainField, gbc); + + + JLabel organisationLabel = new JLabel("Organisation:"); + organisationLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 2; + formPanel.add(organisationLabel, gbc); + + JTextField organisationField = new JTextField(alumniToUpdate.organisation, 20); + organisationField.setPreferredSize(new Dimension(200, 30)); + organisationField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(organisationField, gbc); + + JLabel idLabel = new JLabel("ID:"); + idLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 3; + formPanel.add(idLabel, gbc); + + JTextField idField = new JTextField(alumniToUpdate.id, 20); + idField.setPreferredSize(new Dimension(200, 30)); + idField.setFont(new Font("Arial", Font.PLAIN, 16)); + + gbc.gridx = 1; + formPanel.add(idField, gbc); + + JLabel gmailLabel = new JLabel("Gmail:"); + gmailLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 4; + formPanel.add(gmailLabel, gbc); + + JTextField gmailField = new JTextField(alumniToUpdate.gmail, 20); + gmailField.setPreferredSize(new Dimension(200, 30)); + gmailField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(gmailField, gbc); + + JLabel contactLabel = new JLabel("Contact:"); + contactLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 5; + formPanel.add(contactLabel, gbc); + + JTextField contactField = new JTextField(alumniToUpdate.contact, 20); + contactField.setPreferredSize(new Dimension(200, 30)); + contactField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(contactField, gbc); + + JLabel passwordLabel = new JLabel("Password:"); + passwordLabel.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 0; + gbc.gridy = 6; + formPanel.add(passwordLabel, gbc); + + JTextField passwordField = new JTextField(alumniToUpdate.password, 20); + passwordField.setPreferredSize(new Dimension(200, 30)); + passwordField.setFont(new Font("Arial", Font.PLAIN, 16)); + gbc.gridx = 1; + formPanel.add(passwordField, gbc); + + mainPanel.add(formPanel); + + JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JButton updateButton = new JButton("Update"); + updateButton.setBackground(new Color(124, 252, 200)); + updateButton.setForeground(Color.WHITE); + updateButton.setFont(new Font("Arial", Font.BOLD, 16)); + updateButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String updatedName = nameField.getText(); + String updatedDomain = domainField.getText(); + String updatedOrganisation = organisationField.getText(); + String updatedID = idField.getText(); + String updatedGmail = gmailField.getText(); + String updatedContact = contactField.getText(); + String updatedPassword = passwordField.getText(); + + boolean changed = false; + if (!updatedID.equals(alumniToUpdate.id)) { + if(!alumniDB.alumniMap.containsKey(updatedID)) { + + alumniDB.alumniMap.remove(updatedID); + alumniDB.alumniMap.put(updatedID,new Alumni(updatedName ,alumniToUpdate.branch,alumniToUpdate.passingYear,alumniToUpdate.domain,updatedOrganisation,alumniToUpdate.tags,updatedID,updatedGmail,updatedContact,updatedPassword)); + alumniTree.deleteDomain(alumniToUpdate.domain,alumniToUpdate.id); + alumniTree.deleteOrganisation(alumniToUpdate.organisation,alumniToUpdate.id); + alumniTree.deletePassingYear(alumniToUpdate.passingYear,alumniToUpdate.id); + alumniTree.deleteBranch(alumniToUpdate.branch,alumniToUpdate.id); + + alumniTree.addDomain(updatedDomain,updatedID); + alumniTree.addOrganisation(updatedOrganisation,updatedID); + alumniTree.addPassingYear(alumniToUpdate.passingYear,updatedID); + alumniTree.addBranch(alumniToUpdate.branch,updatedID); + + } + }else { + + if (!updatedName.equals(alumniToUpdate.name)) { + + alumniToUpdate.name = updatedName; + changed = true; + } + if (!updatedDomain.equals(alumniToUpdate.domain)) { + + alumniTree.deleteDomain(alumniToUpdate.domain,alumniToUpdate.id); + alumniTree.addDomain(updatedDomain,alumniToUpdate.id); + + alumniToUpdate.domain = updatedDomain; + + changed = true; + } + if (!updatedOrganisation.equals(alumniToUpdate.organisation)) { + + alumniTree.deleteOrganisation(alumniToUpdate.organisation,alumniToUpdate.id); + alumniTree.addOrganisation(updatedOrganisation,alumniToUpdate.id); + + alumniToUpdate.organisation = updatedOrganisation; + + changed = true; + } + + if (!updatedGmail.equals(alumniToUpdate.gmail)) { + alumniToUpdate.gmail = updatedGmail; + changed = true; + } + if (!updatedContact.equals(alumniToUpdate.contact)) { + alumniToUpdate.contact = updatedContact; + changed = true; + } + if (!updatedPassword.equals(alumniToUpdate.password)) { + alumniToUpdate.password = updatedPassword; + changed = true; + } + } + JOptionPane.showMessageDialog(mainPanel, "Updated Sucessfully !"); + showAlumniOptions(updatedID); + } + }); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setBackground(new Color(255, 99, 71)); + cancelButton.setForeground(Color.WHITE); + cancelButton.setFont(new Font("Arial", Font.BOLD, 16)); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + showAlumniOptions(idField.getText()); + } + }); + + buttonsPanel.add(updateButton); + buttonsPanel.add(cancelButton); + mainPanel.add(buttonsPanel); + + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void displayAlumniPreferenceOptions(String name) { + String[] preferenceOptions = { + "Based on branch", + "Based on passing year", + "Based on domain", + "Based on organization", + "Back" + }; + + JPanel preferencePanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(5, 5, 5, 5); + + for (String option : preferenceOptions) { + JButton button = new JButton(option); + button.setPreferredSize(new Dimension(300, 60)); + + if (option.equals("Back")) { + button.setBackground(new Color(77, 12, 7)); + button.addActionListener(e -> displayStudentOptions(name)); + } else { + button.setBackground(new Color(10, 18, 54)); + button.addActionListener(e -> { + handlePreferenceOption(option,name); + }); + } + button.setForeground(new Color(235, 227, 82)); + preferencePanel.add(button, gbc); + gbc.gridy++; + } + + mainPanel.removeAll(); + mainPanel.setLayout(new BorderLayout()); + mainPanel.add(new JScrollPane(preferencePanel), BorderLayout.CENTER); + mainPanel.revalidate(); + mainPanel.repaint(); + } + + void displayPreferenceChoices(LinkedList options,String name) { + JPanel optionsPanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(5, 5, 5, 5); + + Color blueColor = new Color(11, 18, 48); + Color redColor = new Color(89, 25, 5); + Color mustardColor = new Color(172, 181, 7); + + Font buttonFont = new Font("Arial", Font.BOLD, 14); + Font labelFont = new Font("Times New Roman", Font.ITALIC, 40); + + JLabel optionLabel = new JLabel(" Your choice "); + optionLabel.setFont(labelFont); + optionLabel.setForeground(mustardColor); + optionsPanel.add(optionLabel, gbc); + gbc.gridy++; + for (AlumniTree o : options) { + String option = o.data; + JButton button = new JButton(option); + button.addActionListener(e -> { + displaySpecificAlumni(option, options, name); + }); + button.setPreferredSize(new Dimension(300, 60)); + button.setBackground(blueColor); + button.setForeground(mustardColor); + button.setFont(buttonFont); + optionsPanel.add(button, gbc); + gbc.gridy++; + } + + gbc.weighty = 1; + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> { + displayStudentOptions(name); + }); + backButton.setPreferredSize(new Dimension(100, 30)); + backButton.setBackground(redColor); + backButton.setForeground(mustardColor); + backButton.setFont(buttonFont); + optionsPanel.add(backButton, gbc); + + mainPanel.removeAll(); + mainPanel.setLayout(new BorderLayout()); + mainPanel.add(new JScrollPane(optionsPanel), BorderLayout.CENTER); + mainPanel.revalidate(); + mainPanel.repaint(); + + } + + +private void handlePreferenceOption(String preferenceOption,String name) { + switch(preferenceOption) { + case "Based on branch": + seeAlumniByPreference(1,name); + break; + case "Based on passing year": + seeAlumniByPreference(2,name); + break; + case "Based on domain": + seeAlumniByPreference(3,name); + break; + case "Based on organization": + seeAlumniByPreference(4,name); + break; + case "Back": + displayStudentOptions(name); + break; + } +} + private void handleStudentOption(String option,String name) { + switch(option) { + case "See all alumni": + displayAllAlumni(name); + break; + case "See alumni based on preference": + displayAlumniPreferenceOptions(name); + + break; + case "See alumni based on username": + String uname = JOptionPane.showInputDialog(Main.this, "Enter Alumni Username:"); + if(alumniDB.alumniMap.containsKey(uname)) + displayAlumniDetails(alumniDB.alumniMap.get(uname),name); + else + JOptionPane.showMessageDialog(Main.this, "Incorrect Username"); + + break; + case "See all posts": + + displayAllPosts(name); + break; + case "Back": + JOptionPane.showMessageDialog(Main.this, "Exiting Student Options"); + break; + default: + + break; + } + } + private void displayspecificPosts(String u_name) { + mainPanel.removeAll(); + + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(10, 10, 10, 10); + + JLabel titleLabel = new JLabel("All Posts"); + titleLabel.setFont(new Font("Arial", Font.BOLD, 20)); + + titleLabel.setForeground(Color.WHITE); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0)); + + titleLabel.setOpaque(true); + titleLabel.setBackground(new Color(51, 102, 153)); + titleLabel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(Color.BLACK, 2), + BorderFactory.createEmptyBorder(10, 20, 10, 20) + )); + + mainPanel.add(titleLabel, gbc); + + int preferredWidth = 470; + int preferredHeight = 100; + + int index = 0; + + for (Post post : alumniDB.alumniMap.get(u_name).posts) { + JButton postButton = new JButton("Title: " + post.getTitle() + "
" + + "Date of Event: " + post.getDateOfEvent() + ""); + + postButton.setFont(new Font("Arial", Font.BOLD, 16)); + postButton.setFocusPainted(false); + postButton.setForeground(new Color(245, 160, 49)); + postButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + postButton.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + postButton.setBackground(new Color(10, 26, 54)); + postButton.setOpaque(true); + Border roundedBorder = new EmptyBorder(20, 20, 20, 20) { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.setColor(Color.BLACK); + ((Graphics2D) g).draw(new RoundRectangle2D.Double(x, y, width - 1, height - 1, 20, 20)); + } + }; + postButton.setBorder(roundedBorder); + postButton.addActionListener(e -> displaySpecificPostDetails(post,u_name)); + postButton.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); + + gbc.gridx = 0; + gbc.gridy = index + 1; + gbc.gridwidth = 1; + mainPanel.add(postButton, gbc); + + index++; + + } + + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> showAlumniOptions(u_name)); + gbc.gridx = 0; + gbc.gridy = index + 1; + gbc.gridwidth = 2; + mainPanel.add(backButton, gbc); + + JScrollPane scrollPane = new JScrollPane(mainPanel); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + getContentPane().removeAll(); + getContentPane().add(scrollPane); + revalidate(); + repaint(); + } + private void displayAllPosts(String name) { + mainPanel.removeAll(); + + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(10, 10, 10, 10); + + JLabel titleLabel = new JLabel("All Posts"); + titleLabel.setFont(new Font("Arial", Font.BOLD, 20)); + titleLabel.setForeground(Color.WHITE); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0)); + titleLabel.setOpaque(true); + titleLabel.setBackground(new Color(51, 102, 153)); + titleLabel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(Color.BLACK, 2), + BorderFactory.createEmptyBorder(10, 20, 10, 20) + )); + + mainPanel.add(titleLabel, gbc); + int preferredWidth = 470; + int preferredHeight = 100; + + int index = 0; + for(String a: alumniDB.alumniMap.keySet()) { + for (Post post : alumniDB.alumniMap.get(a).posts) { + // Create button for post + JButton postButton = new JButton("Title: " + post.getTitle() + "
" + + "Date of Event: " + post.getDateOfEvent() + ""); + + // Set button properties + postButton.setFont(new Font("Arial", Font.BOLD, 16)); // Set font and style + postButton.setFocusPainted(false); // Remove focus border + postButton.setForeground(new Color(245, 160, 49)); // Text color (RGB 145, 82, 0) + postButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); // Change cursor to hand + postButton.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // Add inner padding + postButton.setBackground(new Color(10, 26, 54)); // Light gray background color + postButton.setOpaque(true); // Make the button opaque + + // Make button corners rounded + Border roundedBorder = new EmptyBorder(20, 20, 20, 20) { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.setColor(Color.BLACK); + ((Graphics2D) g).draw(new RoundRectangle2D.Double(x, y, width - 1, height - 1, 20, 20)); + } + }; + postButton.setBorder(roundedBorder); + postButton.addActionListener(e -> displayPostDetails(post,name)); + postButton.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); + + gbc.gridx = 0; + gbc.gridy = index + 1; + gbc.gridwidth = 1; + mainPanel.add(postButton, gbc); + + index++; + } + } + + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> displayStudentOptions(name)); + gbc.gridx = 0; + gbc.gridy = index + 1; + gbc.gridwidth = 2; + mainPanel.add(backButton, gbc); + + JScrollPane scrollPane = new JScrollPane(mainPanel); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + getContentPane().removeAll(); + getContentPane().add(scrollPane); + revalidate(); + repaint(); + } + + + private void handleAlumniLogin() { + String username = JOptionPane.showInputDialog(Main.this, "Enter Alumni Username:"); + String password = JOptionPane.showInputDialog(Main.this, "Enter Alumni Password:"); + if (alumniDB.checkAlumni(username, password)) { + JOptionPane.showMessageDialog(Main.this, "Alumni Login Successful!"); + showAlumniOptions(username); + } else { + JOptionPane.showMessageDialog(Main.this, "Invalid Alumni Username or Password."); + } + } + + private void handleStudentLogin() { + String username = JOptionPane.showInputDialog(Main.this, "Enter Student Username:"); + String password = JOptionPane.showInputDialog(Main.this, "Enter Student Password:"); + if (checkStudent(username, password)) { + JOptionPane.showMessageDialog(Main.this, "Student Login Successful!"); + loggedIn = true; + displayStudentOptions(username); + } else { + JOptionPane.showMessageDialog(Main.this, "Invalid Student Username or Password."); + } + } + + private void displayAllAlumni(String name) { + mainPanel.removeAll(); + + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(10, 10, 10, 10); + + JLabel titleLabel = new JLabel("All Alumni From Cummins College"); + titleLabel.setFont(new Font("Arial", Font.BOLD, 20)); + titleLabel.setForeground(Color.WHITE); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0)); + + titleLabel.setOpaque(true); + titleLabel.setBackground(new Color(51, 102, 153)); + titleLabel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(Color.BLACK, 2), + BorderFactory.createEmptyBorder(10, 20, 10, 20) + )); + + mainPanel.add(titleLabel, gbc); + + gbc.gridwidth = 1; + + int columnCount = 2; + int rowCount = (int) Math.ceil((double) AlumniDB.alumniMap.size() / columnCount); // Number of rows + + int preferredWidth = 250; + int preferredHeight = 150; + + int index = 0; + for (String a : AlumniDB.alumniMap.keySet()) { + int rowIndex = index / columnCount; + int colIndex = index % columnCount; + + Alumni alumni = AlumniDB.alumniMap.get(a); + + JButton alumniButton = new JButton("Name: " + alumni.name + "
" + + "Branch: " + alumni.branch + "
" + + "Passing Year: " + alumni.passingYear + "
" + + "Domain: " + alumni.domain + "
" + ); + + alumniButton.setFont(new Font("Arial", Font.PLAIN, 14)); + alumniButton.setFocusPainted(false); + alumniButton.setForeground(Color.WHITE); + alumniButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + alumniButton.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); + alumniButton.setBackground(new Color(64, 64, 64)); + alumniButton.setOpaque(true); + + alumniButton.addActionListener(e -> displayAlumniDetails(alumni,name)); + + alumniButton.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); + + gbc.gridx = colIndex; + gbc.gridy = rowIndex + 1; + mainPanel.add(alumniButton, gbc); + + index++; + } + + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> displayStudentOptions(name)); + gbc.gridx = 0; + gbc.gridy = rowCount + 1; + gbc.gridwidth = 2; + mainPanel.add(backButton, gbc); + + JScrollPane scrollPane = new JScrollPane(mainPanel); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + getContentPane().removeAll(); + getContentPane().add(scrollPane); + revalidate(); + repaint(); + } + + + private void displaySpecificAlumni(String opt, LinkedList alumniList,String name) { + + AlumniTree lst = null; + for (AlumniTree o : alumniList) { + lst = o; + if (o.data.equals(opt)) { + break; + } + } + mainPanel.removeAll(); + + mainPanel.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(10, 10, 10, 10); + + JLabel titleLabel = new JLabel("Alumni"); + titleLabel.setFont(new Font("Arial", Font.BOLD, 20)); + titleLabel.setForeground(Color.WHITE); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0)); + + titleLabel.setOpaque(true); + titleLabel.setBackground(new Color(51, 102, 153)); + titleLabel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(Color.BLACK, 2), + BorderFactory.createEmptyBorder(10, 20, 10, 20) + )); + + mainPanel.add(titleLabel, gbc); + + gbc.gridwidth = 1; + + int columnCount = 2; + int rowCount = (int) Math.ceil((double) alumniList.size() / columnCount); + int preferredWidth = 250; + int preferredHeight = 150; + + int index = 0; + for (AlumniTree a : lst.child) { + Alumni alumni = AlumniDB.alumniMap.get(a.data); + + int rowIndex = index / columnCount; + int colIndex = index % columnCount; + + JButton alumniButton = new JButton("Name: " + alumni.name + "
" + + "Branch: " + alumni.branch + "
" + + "Passing Year: " + alumni.passingYear + "
" + + "Organisation: " + alumni.organisation + "
" ); + + + alumniButton.setFont(new Font("Arial", Font.PLAIN, 14)); + alumniButton.setFocusPainted(false); + alumniButton.setForeground(Color.WHITE); + alumniButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + alumniButton.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); + alumniButton.setBackground(new Color(64, 64, 64)); + alumniButton.setOpaque(true); + + alumniButton.addActionListener(e -> displayAlumniDetails(alumni,name)); + + alumniButton.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); + + gbc.gridx = colIndex; + gbc.gridy = rowIndex + 1; + mainPanel.add(alumniButton, gbc); + + index++; + } + + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> { + displayAlumniPreferenceOptions(name); + }); + gbc.gridx = 0; + gbc.gridy = rowCount + 1; + gbc.anchor = GridBagConstraints.NORTHWEST; + gbc.insets = new Insets(10, 10, 10, 10); + mainPanel.add(backButton, gbc); + + JScrollPane scrollPane = new JScrollPane(mainPanel); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + getContentPane().removeAll(); + getContentPane().add(scrollPane); + revalidate(); + repaint(); + } + private void displayAlumniDetails(Alumni alumni, String name) { + JFrame detailsFrame = new JFrame("Alumni Details"); + detailsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + detailsFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + + Color darkBlue = new Color(148, 16, 25); + Color mustard = new Color(7, 10, 23); + Color lightBlue = new Color(223, 243, 247); + + JPanel detailsPanel = new JPanel(); + detailsPanel.setBackground(lightBlue); + detailsPanel.setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(10, 10, 10, 10); + gbc.anchor = GridBagConstraints.CENTER; + + gbc.gridx = 0; + gbc.gridy = 0; + JLabel nameLabel = createLabel("" + alumni.name + ""); + detailsPanel.add(nameLabel, gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Branch: " + alumni.branch + ""), gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Passing Year: " + alumni.passingYear + ""), gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Domain: " + alumni.domain + ""), gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Organisation: " + alumni.organisation + ""), gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Contact: " + alumni.contact + ""), gbc); + + gbc.gridy++; + detailsPanel.add(createLabel("Gmail: " + alumni.gmail + ""), gbc); + + if (!alumni.posts.isEmpty()) { + gbc.gridy++; + JLabel postsLabel = createLabel("Posts"); + detailsPanel.add(postsLabel, gbc); + + for (Post post : alumni.posts) { + gbc.gridy++; + JButton postButton = new JButton("Title: " + post.Title + "
" + + "Post Date: " + post.postDate + "
" + + "Deadline of Registration: " + post.deadlineOfRegistration + ""); + postButton.setHorizontalAlignment(SwingConstants.CENTER); // Center text horizontally + postButton.setVerticalAlignment(SwingConstants.CENTER); // Center text vertically + postButton.setPreferredSize(new Dimension(400, 100)); // Set preferred size for each button + postButton.setBackground(mustard); // Set background color (mustard) + postButton.setForeground(Color.WHITE); // Set font color to dark blue + postButton.setFont(new Font("Arial", Font.PLAIN, 14)); // Set font + postButton.setBorder(BorderFactory.createLineBorder(darkBlue)); // Add border + + postButton.addActionListener(e -> { + displayPostDetails(post, name); + }); + + detailsPanel.add(postButton, gbc); + } + } + + gbc.gridy++; + gbc.anchor = GridBagConstraints.CENTER; + gbc.fill = GridBagConstraints.NONE; + JButton backButton = new JButton("Back"); + backButton.addActionListener(e -> { + + detailsFrame.dispose(); + }); + backButton.setPreferredSize(new Dimension(150, 40)); + backButton.setBackground(darkBlue); + backButton.setForeground(Color.WHITE); + backButton.setFont(new Font("Arial", Font.BOLD, 16)); + backButton.setBorderPainted(false); + backButton.setFocusPainted(false); + backButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + detailsPanel.add(backButton, gbc); + + JScrollPane scrollPane = new JScrollPane(detailsPanel); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + + detailsFrame.add(scrollPane); + + detailsFrame.setLocationRelativeTo(null); + + detailsFrame.setVisible(true); + } + + + private void displayPostDetails(Post post,String name) { + JFrame detailsFrame = new JFrame("Post Details"); + detailsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + detailsFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + + JPanel detailsPanel = new JPanel(new GridBagLayout()); + detailsPanel.setBackground(new Color(30, 30, 60)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 10, 5, 10); + + JLabel titleLabel = new JLabel(post.getTitle()); + titleLabel.setFont(new Font("Monotype Corsiva", Font.BOLD, 50)); + titleLabel.setForeground(Color.WHITE); + detailsPanel.add(titleLabel, gbc); + + gbc.gridy++; + + addDetailLabel(detailsPanel, gbc, "Post Date:", post.getPostDate()); + addDetailLabel(detailsPanel, gbc, "Deadline of Registration:", post.getDeadlineOfRegistration()); + addDetailLabel(detailsPanel, gbc, "Date of Event:", post.getDateOfEvent()); + addDetailLabel(detailsPanel, gbc, "Description:", post.getPostDescription()); + addDetailLabel(detailsPanel, gbc, "Tags:", String.join(", ", post.postTags)); + + JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + buttonsPanel.setBackground(new Color(30, 30, 60)); + JButton backButton = new JButton("Back"); + backButton.setBackground(Color.RED); + backButton.setForeground(Color.WHITE); + backButton.setFont(new Font("Helvetica", Font.BOLD, 16)); + backButton.addActionListener(e -> { + displayStudentOptions(name); + detailsFrame.setVisible(false); + + }); + buttonsPanel.add(backButton); + + JButton registerButton = new JButton("Register Now"); + registerButton.setBackground(Color.RED); + registerButton.setForeground(Color.WHITE); + registerButton.setFont(new Font("Helvetica", Font.BOLD, 16)); + registerButton.addActionListener(e -> { + String email = JOptionPane.showInputDialog(detailsFrame, "Enter your email:"); + String password = JOptionPane.showInputDialog(detailsFrame, "Enter your password:"); + Student st = null; + boolean f= false; + for(Student s:StudentDB.studentsList){ + if(s.emailId.equals(email) &&s.password.equals(password) ){ + st=s; + f= true; + break; + } + } + if(!f) { + JOptionPane.showMessageDialog(detailsFrame, "Incorrect Credentials"); + return; + } + boolean alreadyRegistered = false; + + for (Registration registration : post.registeredStudents) { + if (registration.emailId.equals(email)) { + alreadyRegistered = true; + break; + } + } + + if (alreadyRegistered) { + JOptionPane.showMessageDialog(detailsFrame, "You are already registered for this post."); + } else { + + post.registeredStudents.add(new Registration(st.rollNum,st.name,st.contactNo,st.emailId)); + JOptionPane.showMessageDialog(detailsFrame, "Registered sucessfully"); + displayStudentOptions(name); + } + }); + buttonsPanel.add(registerButton); + + gbc.gridy++; + detailsPanel.add(buttonsPanel, gbc); + + ArrayList registrations = post.registeredStudents; + if (!registrations.isEmpty()) { + JLabel registrationsLabel = new JLabel("Registrations:"); + registrationsLabel.setFont(new Font("Arial", Font.BOLD, 16)); + registrationsLabel.setForeground(Color.WHITE); + gbc.gridy++; + detailsPanel.add(registrationsLabel, gbc); + + gbc.gridy++; + + int maxWidth = 0; + for (Registration registration : registrations) { + JButton tempButton = new JButton(registration.name); + int width = tempButton.getPreferredSize().width; + if (width > maxWidth) { + maxWidth = width; + } + } + + for (Registration registration : registrations) { + JButton registrationButton = new JButton(registration.name); + registrationButton.setPreferredSize(new Dimension(maxWidth, registrationButton.getPreferredSize().height)); + registrationButton.setFont(new Font("Arial", Font.PLAIN, 14)); + registrationButton.setForeground(Color.WHITE); + registrationButton.setBackground(new Color(100, 100, 100)); + registrationButton.addActionListener(e -> { + }); + detailsPanel.add(registrationButton, gbc); + gbc.gridy++; + } + } + + detailsFrame.add(detailsPanel); + + detailsFrame.setVisible(true); + } + + private void displaySpecificPostDetails(Post post,String name) { + JFrame detailsFrame = new JFrame("Post Details"); + detailsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + detailsFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + + JPanel detailsPanel = new JPanel(new GridBagLayout()); + detailsPanel.setBackground(new Color(30, 30, 60)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 10, 5, 10); + + JLabel titleLabel = new JLabel(post.getTitle()); + titleLabel.setFont(new Font("Monotype Corsiva", Font.BOLD, 50)); + titleLabel.setForeground(Color.WHITE); + detailsPanel.add(titleLabel, gbc); + + gbc.gridy++; + + addDetailLabel(detailsPanel, gbc, "Post Date:", post.getPostDate()); + addDetailLabel(detailsPanel, gbc, "Deadline of Registration:", post.getDeadlineOfRegistration()); + addDetailLabel(detailsPanel, gbc, "Date of Event:", post.getDateOfEvent()); + addDetailLabel(detailsPanel, gbc, "Description:", post.getPostDescription()); + addDetailLabel(detailsPanel, gbc, "Tags:", String.join(", ", post.postTags)); + + JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + buttonsPanel.setBackground(new Color(30, 30, 60)); + JButton backButton = new JButton("Back"); + backButton.setBackground(Color.RED); + backButton.setForeground(Color.WHITE); + backButton.setFont(new Font("Helvetica", Font.BOLD, 16)); + backButton.addActionListener(e -> { + showAlumniOptions(name); + detailsFrame.setVisible(false); + }); + buttonsPanel.add(backButton); + + gbc.gridy++; + detailsPanel.add(buttonsPanel, gbc); + + ArrayList registrations = post.registeredStudents; + if (!registrations.isEmpty()) { + JLabel registrationsLabel = new JLabel("Registrations:"); + registrationsLabel.setFont(new Font("Arial", Font.BOLD, 16)); + registrationsLabel.setForeground(Color.WHITE); + gbc.gridy++; + detailsPanel.add(registrationsLabel, gbc); + + gbc.gridy++; + + int maxWidth = 0; + for (Registration registration : registrations) { + JButton tempButton = new JButton(registration.name); + int width = tempButton.getPreferredSize().width; + if (width > maxWidth) { + maxWidth = width; + } + } + + for (Registration registration : registrations) { + JButton registrationButton = new JButton(registration.name); + registrationButton.setPreferredSize(new Dimension(maxWidth, registrationButton.getPreferredSize().height)); + registrationButton.setFont(new Font("Arial", Font.PLAIN, 14)); + registrationButton.setForeground(Color.WHITE); + registrationButton.setBackground(new Color(100, 100, 100)); + + detailsPanel.add(registrationButton, gbc); + gbc.gridy++; + } + } + + detailsFrame.add(detailsPanel); + + detailsFrame.setVisible(true); + } + + private void addDetailLabel(JPanel panel, GridBagConstraints gbc, String label, String value) { + JLabel detailLabel = createLabel("" + label + " " + value + ""); + detailLabel.setForeground(Color.YELLOW); + panel.add(detailLabel, gbc); + gbc.gridy++; + } + + private JLabel createLabel2(String text) { + JLabel label = new JLabel(text); + label.setFont(new Font("Arial", Font.PLAIN, 18)); + label.setForeground(new Color(145, 82, 0)); + return label; + } + + + private JLabel createLabel(String text) { + JLabel label = new JLabel(text); + label.setFont(new Font("Arial", Font.PLAIN, 14)); + label.setForeground(Color.BLACK); + return label; + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Main mainGUI = new Main(); + mainGUI.setVisible(true); + } + }); + } +} diff --git a/Team 31 - Cummins Connect/Post.java b/Team 31 - Cummins Connect/Post.java new file mode 100644 index 0000000..0e299a6 --- /dev/null +++ b/Team 31 - Cummins Connect/Post.java @@ -0,0 +1,169 @@ +package buffer; + + + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.ArrayList; + +class Post { + + + + String Id; + + + + String Title; + + + + String postDate; + + + + String deadlineOfRegistration; + + + + String dateOfEvent; + + + + String postDescription; + + + + ArrayList postTags; + + + + ArrayList registeredStudents= new ArrayList<>(); + + + + public Post(String Id, String Title, String postDate, String deadlineOfRegistration, String dateOfEvent, + + + + String postDescription, ArrayList postTags) { + + + + this.Id = Id; + + + + this.Title = Title; + + + + this.postDate = postDate; + + + + this.deadlineOfRegistration = deadlineOfRegistration; + + + + this.dateOfEvent = dateOfEvent; + + + + this.postDescription = postDescription; + + + + this.postTags = postTags; + + + + } + + + + + + + + public String getId() { + + + + return Id; + + + + } + + + + public String getTitle() { + + + + return Title; + + + + } + + + + public String getPostDate() { + + + + return postDate; + + + + } + + + + public String getDeadlineOfRegistration() { + + + + return deadlineOfRegistration; + + + + } + + + + public String getDateOfEvent() { + + + + return dateOfEvent; + + + + } + + + + public String getPostDescription() { + + + + return postDescription; + + + + } + + + + public ArrayList getTags() { + + return postTags; + + + + } + +} diff --git a/Team 31 - Cummins Connect/Registration.java b/Team 31 - Cummins Connect/Registration.java new file mode 100644 index 0000000..7db67e5 --- /dev/null +++ b/Team 31 - Cummins Connect/Registration.java @@ -0,0 +1,31 @@ +package buffer; + + +public class Registration { + + String rollNum; + + String name; + + String contactNo; + + String emailId; + + + + Registration(String rollNum,String name,String contactNo,String emailId) + + { + + this.rollNum=rollNum; + + this.name=name; + + this.contactNo=contactNo; + + this.emailId=emailId; + + } + + +} diff --git a/Team 31 - Cummins Connect/StudentDB.java b/Team 31 - Cummins Connect/StudentDB.java new file mode 100644 index 0000000..08d6c18 --- /dev/null +++ b/Team 31 - Cummins Connect/StudentDB.java @@ -0,0 +1,126 @@ +package buffer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import java.util.regex.Pattern; +class Student { + + String rollNum; + String name; + String contactNo; + String emailId; + String branch; + int yearOfStudy; + double GPA; + String areaOfInterest; + String workExperience; + String password; + + + public Student(String rollNum, String name, String contactNo, String emailId, String branch, int yearOfStudy, + double GPA, String areaOfInterest, String workExperience,String password) { + + this.rollNum = rollNum; + this.name = name; + this.password= password; + this.contactNo = contactNo; + this.emailId = emailId; + this.branch = branch; + this.yearOfStudy = yearOfStudy; + this.GPA = GPA; + this.areaOfInterest = areaOfInterest; + this.workExperience = workExperience; + + } +} +public class StudentDB { + public static boolean isStrongPassword(String password) { + // Check length + if (password.length() < 8) { + return false; + } + + // Check for uppercase, lowercase, digits, and special characters using regex + if (!Pattern.compile("[A-Z]").matcher(password).find() || + !Pattern.compile("[a-z]").matcher(password).find() || + !Pattern.compile("[0-9]").matcher(password).find() || + !Pattern.compile("[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?]").matcher(password).find()) { + return false; + } + + return true; + } + + static Scanner sc = new Scanner(System.in); + + +// riddhi@xyzcollege.in +// @#*Su123sm + static ArrayList studentsList = new ArrayList<>(); + + StudentDB() { + studentsList.add(new Student("ABC1234567", "Riddhi Sharma", "9876543210", "riddhi@xyzcollege.in", + "Computer Science", 3, 3.8, "Software Development", "Intern at CompanyX","@#*Su123sm")); + studentsList.add(new Student("DEF2345678", "Rohan Desh", "9876543211", "rohan@xyzcollege.in", + "Electrical Engineering", 2, 3.5, "Data Analysis", "Data Analyst at CompanyY","@Rohan123")); + studentsList.add(new Student("GHI3456789", "Ali Singh", "9876543212", "ali@xyzcollege.in", + "Mechanical Engineering", 4, 3.2, "Product Management", "Product Manager at CompanyZ","Ali&21")); + studentsList.add(new Student("ABC1234567", "Riddhi Sharma", "9876543210", "1", + "Computer Science", 3, 3.8, "Software Development", "Intern at CompanyX","1")); + } + public Student retriveStudent(String uname) + { + for(Student s:studentsList) + { + if(s.emailId==uname) + { + return s; + } + } + return null; + } + static void studentInput() { + + System.out.println("-------------------------------------"); + System.out.print("Enter Roll Number : "); + String rollNum = sc.nextLine(); + System.out.print("Enter Name : "); + String name = sc.nextLine(); + + System.out.print("Enter Password : "); + String pass = sc.nextLine(); + while(!isStrongPassword(pass)){ + System.out.print("Your password is weak : \n1) Re-enter Password :\n2) Exit"); + int ch = sc.nextInt(); + sc.nextLine(); + if(ch==1) + pass = sc.nextLine(); + else { + System.out.println("Successfull !"); + return; + } + } + System.out.print("Enter Contact Number : "); + String contactNo = sc.nextLine(); + System.out.print("Enter Email Id : "); + String emailId = sc.nextLine(); + System.out.print("Enter Branch : "); + String branch = sc.nextLine(); + System.out.print("Enter Year of Study : "); + int yearOfStudy = sc.nextInt(); + sc.nextLine(); + System.out.print("Enter GPA : "); + double GPA = sc.nextDouble(); + sc.nextLine(); + System.out.print("Enter Area of Interest : "); + String areaOfInterest = sc.nextLine(); + System.out.print("Enter Work Experience : "); + String workExperience = sc.nextLine(); + System.out.println("-------------------------------------"); + + studentsList.add(new Student(rollNum, name, contactNo, emailId, branch, yearOfStudy, GPA, areaOfInterest, workExperience,pass)); + System.out.println("Successfull !"); + } + +}