"Data Structure Course Practice"_01_Student Score File Management System_Preview Report

1. Experiment topics and requirements

  • Enter student information, including student ID, name, major, grades, total scores, and rankings of the four courses;

  • The system can browse, add, delete and modify student information;

  • Determine the ranking and information output according to the student's performance, two-way bubble sorting, Hill sorting, quick sorting, heap sorting;

  • The student information can be inquired upon request, according to the student number or name;

  • Information modification can only modify the grades of four courses

  • File access student information

2. Programming language and development environment

1. Programming language:
choiceJava, Because I improved Java in project 01 last semester , now I am used to writing in Java

2. Development environment:
choiceIntelliJ IDEA, More convenient to use

Three, experimental ideas

1. Thinking about initial data processing

  1. Create a package data, which containsType studentDataTo deal with students’ information and data problems, create a package Student, which containsClass Student, To deal with the student object.

  2. Student information includes student ID, name, major, grades, total scores, and rankings of the four courses in 9 categories, so it can be processed by a set to constructCollection studentList

  3. Create a package Dao, includingClass studentDao, Used to process data operations.

2. Student object processing

  1. Construct a constructor with parameters in the Student class, and in the studentData class, initialize the data type of student data, fill in the linked list. add () method , complete the initialization of the data class.

  2. There are 9 elements of the student object, of which the total score can be replaced by the results of the four subjects. Among the constructors with parameters, ranking and total score are not included. These two elements need to be calculated separately.

  3. Create a method in DaorankByScoreAllPerform ranking and calculate the total score in the student class constructor. At this time, the total score is not displayed, but the calculation has been completed.

3. Operation processing

  1. The new package serves is used to expand the operation service, create a newClass serves, Used as a service.

  2. Create a new class main as the startup switch of the program. Need to instantiate the data of other classes used in this class.

  3. Build the switch method in the serves classbegin, The initial interface displays the initialized data, and then select the function, throughswitch statementPerform a function jump.

  4. From the start method, select1redirect toAdd student informationFunction, choice2redirect toDelete student informationFunction, choice3redirect toModify student informationFunction, choice4redirect toSort student informationFunction, choice5redirect toQuery student informationFunction, choice6redirect toPrint student informationFunction, choice7redirect toExit systemFeatures.

4. Method description

  1. Add student information:
    Add a method in the serves class : addStudent , you need to enter the relevant information of the student, and then add a method in the studentDao class to add student information. Then call it in the addStudent method.

  2. Delete student information:
    In serves class add methods: deleteStudent , you need to enter to remove students learn numbers, can be passed as a parameter, then studentDao class add methods, delete student information. Then call it in the deleteStudent method.

  3. Modify student information:
    Add a method in the serves class : modifyStudent , you need to enter the student ID of the student to be modified, which can be passed in as a parameter, and then add a method in the studentDao class to delete student information. Then call it in the modifyStudent method.

  4. Sort student information:
    This function requires secondary selection and four sorting methods. Two-way bubble sort, Hill sort, quick sort, heap sort. Write the three methods in Dao in turn, then select in the service class, and then call the methods in Dao.

Two-way bubble sorting : The difference between this algorithm and bubble sorting is that sorting is performed in the sequence in both directions. The outer layer compares the left and right boundaries l<r, and the inner layer compares from left to right in a loop, and the higher value is placed behind. ; A loop from right to left, taking the low value to the front; efficiency, O(N^2), not faster than ordinary bubbling.

Hill sorting : group the records by a certain increment of the target, and use the direct insertion sorting algorithm to sort each group; as the increment decreases, each group contains more and more keywords. When the increment decreases to 1, The entire file is divided into one group, and the algorithm terminates.

Quick sorting : Separate the records to be sorted into two independent parts by sorting. One part of the records has a smaller keyword than the other part. You can continue to sort the two parts of the records separately to achieve the entire sequence. sequence.

Heap sorting : refers to a sorting algorithm designed by using the data structure of the heap. Heap is an approximately complete binary tree structure, and at the same time satisfies the nature of accumulation: that is, the key value or index of the child node is always less than (or greater than) its parent node.

  1. Query student information:
    Set the query function in the service class, in which the query method in Dao is called. There are two options, query by student number and query by name, which also need to be selected.

  2. Print student information:
    You can directly call the main interface at the beginning. Because it is a general function written in Dao, it can be reused easily without rewriting, making the code more concise.

Fourth, preview summary

In this preview, there is a big problem with the sorting algorithm, and it needs to be inquired to do it. At the same time, there is also a very important realization that functions that are used repeatedly can be placed in a single class, which can be convenient for later Repeated use, and the code will appear very neat and concise.

Guess you like

Origin blog.csdn.net/jsinszjjs/article/details/114022804