Java project案例 java项目案例 code案例
当前位置:以往案例 > >Java project案例 java项目案例 code案例

Java project案例

Java project案例 student’s seating assignment.Feel free to reuse any of the code from the modules to complete the requirements.

Java project案例Java project案例
For this project, you will create a class for an elementary school that will allow a teacher to enter each student’s seating assignment. Java project案例

Occasionally, the teacher may need to switch the seating assignment of a student.  If there is a seat available, the student is moved. If all of the seats are already assigned, the teacher will have two students trade seats.     Java project案例

Feel free to reuse any of the code from the modules to complete the requirements.

Note: I do not award or deduct points for style, but to make grading easier on me, please to do use comments to explain your code.  I find explanatory comments distracting.  If you need comments for your own use, save a copy for yourself, then remove the comments before uploading your work.Java project案例

User Interface Logic
Main Class
This class will be responsible for any and all user interaction. This means that if you want to get input from the user, or display output to the user, all of that code must be in the main class.  This keeps all user interaction in one class, separate from the business logic of the program.  By keeping your user interface logic in a separate class, it will make it SO much easier to reuse your business logic classes in other types of applications, like GUI applications, later on.Java project案例

Create a main method in its own class.  The main method should create an object of the seatingChart class (defined below) and call its methods for testing purposes.  Java project案例
Business Logic
Student Class
private member data
String first
String last
int student id
public methods:
public Student(String first, String last, int id): A constructor with parameters to set the instance variables.
public String toString(): This method should return a string that contains all of the private member data as a single string.  Be kind to your client and make it readable.
An accessor (getter) method for each instance variable.
SeatingChart Class
Create a separate class called seatingChartthat has an array of student objects as a private instance member of the seattingChart class.  The array of student objects should be size 20. The seatingChart class must also have these methods:
public void addStudent(String first, String last, int id, int seatnum) —This method should add one student to the specified seat number on the seating chart. Position 0 of the array represents the seat closest to the teacher’s desk.  Java project案例 The array index will represent each seat number for the seating assignments.
public int findStudent(String first) — This method should search the seating chart and return the seat number of a specified student first name.  Remember, The array index will represent each seat number for the seating assignments, so this method should return the array index number as the seat number. This method should use the binary search algorithm described in the modules.Java project案例
public void swapStudent(String first, int targetSeat) —This method should find the students name in the array by calling the findStudent method, and then move the student object from his or her original seat to the target seat as a swap.  No students should be lost;  if the target seat is not empty, the students will trade seating assignments.Java project案例
public String toString() — This method will return a string that holds the entire seating chart, but this string will only include each seat number (empty or filled) and only the first name of the student in that seat. You can choose how the information is formatted in the string, but be kind to your client and make it readable. Java project案例
Paste the output of your program in the submission window and upload your .java file(s) to submit your work.Java project案例

Java project案例Java project案例