hi,
I am at the beginning of my assignment and I have some problems, here is my code:
import java.io.*; import java.util.*; public class StudentDatabase { static int STUDENT_SIZE = 20; Student[] students = new Student[STUDENT_SIZE]; int length = 0; //the current size of the array Scanner scan = new Scanner(System.in); public static void main(String[] args) { Menu menu = new Menu(); StudentDatabase aStudentDatabase=null; do{ menu.showMenu(); int aChoice = 0; aChoice=menu.choice(); while(aChoice==0) { System.err.println ( "Unrecognized option, please select again" ); menu.showMenu(); aChoice=menu.choice(); } if(aStudentDatabase==null) { aStudentDatabase = new StudentDatabase(); } switch(aChoice) { case 1: aStudentDatabase.addStudent(); break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: aStudentDatabase.displayStudentDetails(); break; case 7: break; case 8: System.exit(0); break; } } while(true); } public boolean Start() { return true; } public void addStudent() { students[length++] = new Student(); } public boolean deleteStudent() { return true; } public boolean addModule() { return true; } public boolean deleteModule() { return true; } public boolean assignModule() { return true; } public void displayStudentDetails() { System.out.println("Student Name:" + student.getFirstName() +" "+ student.getLastName() + " Enrollment on:" + student.getEnrollmentDate()); } public boolean displayModuleDetails() { return true; } }
import java.io.*; import java.util.*; public class Menu { // Scanner for user input public Scanner scan; public int choice; public void showMenu() { System.out.println("*****************************"); System.out.println("Welcome to the Student Database!"); System.out.println ( "***********************************" ); System.out.println ( "*************MAIN MENU*************" ); System.out.println ( "***********************************" ); System.out.println ( "Select (1) to Add Student\nSelect (2) to Delete Student\nSelect (3) to Add Module\nSelect (4) to Delete Module\nSelect (5) to Assign Student to Module\nSelect (6) to Display Student Details\nSelect (7) to Display Module Details\nSelect (8) to Exit Program\n"); } public int choice() { scan = new Scanner(System.in); System.out.print("Please select an option: "); //Read the input from the user choice = scan.nextInt(); //Return the user's choice return choice; } }
import java.io.*; import java.util.*; public class Student { private String firstName; private String lastName; private String enrollmentDate; // better would be to use util.Date not String ?? private Scanner scan; // default constructor - initializes default attr values public Student() { scan = new Scanner(System.in); System.out.print("Student Name:"); firstName = scan.next(); System.out.print("Student Surname:"); lastName = scan.next(); System.out.print("Enrollment Date:"); enrollmentDate = scan.next(); } public Student(String newFirstName, String newLastName, String newEnrollmentDate) { this.firstName = newFirstName; this.lastName = newLastName; this.enrollmentDate = newEnrollmentDate; } //setters public void setFirstName (String newFirstName) { firstName = newFirstName; } public void setLastName (String newLastName) { lastName = newLastName; } public void setEnrollmentDate (String newEnrollmentDate) { enrollmentDate = newEnrollmentDate; } //getters public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getEnrollmentDate() { return enrollmentDate; } }
1. How I can implement addStudent method in the StudentDatabase class?
2. How to implement the constructor in the Studnet class?
3. How I can implement displayStudentDetails method?
Can you drop me few tips here please?
thanks
E