Question
In a project based on my codes I need to code this School Management system main with following requirements Main Entry in the package in
In a project based on my codes I need to code this School Management system main with following requirements
Main Entry
in the package in the src/main/java folder named: jpa.mainrunner, in this package you will make a class as SMSRunner. This class will be used to run the School Management System.
No. | Return Type | Class Name | Method Name | Input Parameters |
1 | void | SMSRunner | main - -This method displays and prompts the user to select one of the following with the option: 1. Student: This allows the user to enter his/her email and password and check whether or not those credentials are valid, in order to log in. If the credentials are invalid the program should end with an appropriate message to the student. If the credentials are valid, the student is logged in and all the classes the Student is registered to should be displayed. Displays and prompt the student to select one of the following two additional numeric (1 or 2) options that are available: 1) Register to Class: This displays all the courses in the database and allows the student to select a course in which the student wished to be registered. If the Student is already registered in that course, display the message "You are already registered in that course!", otherwise, register the student to that course and save this result in your database. Also, show the updated registered courses list for that student. After that end the program with an appropriate message. 2) Logout: Which ends the program with an appropriate message. 2. quit: which ends the program with an appropriate message. | String[] args |
package jpa.entitymodels; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; @Entity @Table(name = "student") @NamedQueries({ @NamedQuery( name="Select_All_Students", query="from Student"), @NamedQuery( name="Select_Student_By_Email", query="Select c from Student c where c.sEmail = :email") }) public class Student implements Serializable{ private static final long serialVersionUID = 1L; //class variables @Id @Column(name = "Student_Email", nullable = false, length = 50) private String sEmail; @Column(name = "student_FullName", nullable = false, length = 50) private String sName; @Column(name = "student_password", nullable = false, length = 50) private String sPass; //relationship @ManyToMany(targetEntity=Course.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER) private List sCourses = new ArrayList(); public Student(String sEmail, String sName, String sPass, List sCourses) { this.sEmail = sEmail; this.sName = sName; this.sPass = sPass; this.sCourses = sCourses; } //default constructor public Student(){} //getters setters public String getsEmail() { return sEmail; } public void setsEmail(String sEmail) { this.sEmail = sEmail; } public String getsName() { return sName; } public void setsName(String sName) { this.sName = sName; } public String getsPass() { return sPass; } public void setsPass(String sPass) { this.sPass = sPass; } public List getsCourses() { return sCourses; } public void setsCourses(List sCourses) { this.sCourses = sCourses; } public static long getSerialversionuid() { return serialVersionUID; } }
package jpa.entitymodels; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; @Entity @Table @NamedQueries({ @NamedQuery( name="Select_All_Courses", query="from Course"), }) public class Course implements Serializable { private static final long serialVersionUID = 1L; //Select_All_Courses //class variables @Id @Column(name = "Course_Id", nullable = false) private int cId; @Column(name = "Course_Name", nullable = false, length = 50) private String cName; @Column(name = "Course_Instructor", nullable = false, length = 50) private String cInstructorName; public Course(int cId, String cName, String cInstructorName) { this.cId = cId; this.cName = cName; this.cInstructorName = cInstructorName; } //default constructor public Course() {} //generate getters setters public int getcId() { return cId; } public void setcId(int cId) { this.cId = cId; } public String getcName() { return cName; } public void setcName(String cName) { this.cName = cName; } public String getcInstructorName() { return cInstructorName; } public void setcInstructorName(String cInstructorName) { this.cInstructorName = cInstructorName; } }
package jpa.dao; import java.util.List; import jpa.entitymodels.Course; import jpa.entitymodels.Student; public interface StudentDAO { List getAllStudents(); Student getStudentByEmail(String studentEmail); Boolean validateStudent(String studentEmail, String password); void registerStudentToCourse(String studentEmail, int courseId); List getStudentCourses(String studentEmail); }
package jpa.dao; import java.util.List; import jpa.entitymodels.Course; public interface CourseDAO { List getAllCourses(); }
package jpa.service; import java.util.List; import jpa.dao.StudentDAO; import jpa.entitymodels.Course; import jpa.entitymodels.Student; class StudentService implements StudentDAO{ public List getAllStudents(){ // db call return null; } public Student getStudentByEmail(String sEmail){ // after getting the list of all the students // we can iterate the list and then check whether the email id is same // as the email id we are looking for // we will return that student // else we will return null return null; } public Boolean validateStudent(String sEmail,String sPass){ // return true; } public List getStudentCourses(String sEmail){ // find the student with this email id // then will return the list of the course the student will have return null; } public void registerStudentToCourse(String sEmail,int cId){ // to register a student to a course // add the course to the list of this courses of the student // add this student to the list of the students the course have return; } }
package jpa.service; import java.util.List; import jpa.dao.CourseDAO; import jpa.entitymodels.Course; class CourseService implements CourseDAO{ public List getAllCourses(){ /// return the list from DB return null; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To complete the requirements for the School Management System main entry point you will need to create a class named SMSRunner in the package jpamainr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started