The textbook p448 example15_41. List to add their own number after the three students, the study number is the last three from the 1th to join 2. Submit run result 3. Carve push code into code cloud
In data structures and algorithms, sorting is a very important operation, to allow a class to be sorted, there are two ways:-There are classes of source code, for a member variable ordering, let the class implement comparable interface, call Collection.sort (List)-no class source code, or a variety of sorts, create a new class, implement the comparator interface call Collection.sort (List, Compatator) for the following student class, using comparator programming to complete the following functions: 1. Create a new student list in the test class Studenttest, including a total of 5 students and two students before and after the student number, giving the results of the run (before sorting, after sorting) 2. The 5 students were ordered by the number and the total scores, and submitted two comparator code 3. Class submit code to the code cloud class Student {private string id;//notation private string name;//represents the name private int age;//Age private Do Uble computer_score;//represents the results of the computer course private double english_score;//English class results private double maths_score;//indicates the grade of the math class PR Ivate Double total_score;//represents the total total of private double ave_score; Represents the average score public Student (string ID, string name) {this.id = ID; THIS.name = name;} Public Student (string ID, string name, char sex, int.) {This (ID, name); This.sex = sex; This.age = age;} Public String GetId () {return ID;} Gets the number of the current object, public double Getcomputer_score () {return computer_score;} Get the current object of the computer course score, pubLIC double Getmaths_score () {return maths_score;} Gets the current object's math course score, public double Getenglish_score () {return english_score;} Gets the English course score for the current object, public void SetId (String id) {this.id=id;} Sets the ID value of the current object, public void Setcomputer_score (double computer_score) {This.computer_score=computer_score;} Sets the Computer_score value of the current object, public void Setenglish_score (double english_score) {This.english_score=english_score;} Sets the English_score value of the current object, public void Setmaths_score (double maths_score) {This.maths_score=maths_score;} Sets the Maths_score value of the current object, public double Gettotalscore () {return computer_score+maths_score+english_score;} Calculate the overall scores of Computer_score, Maths_score and English_score. Public double Getavescore () {return Gettotalscore ()/3;} Calculates the average score of Computer_score, Maths_score, and English_score in each class. }class Undergraduate extends student{private String ClassID; Public undergraduate (string ID, string name, char sex, int age,string classID) { Super (Id,name,sex,age); This.classid=classid; } public String GetClassID () {return classID; } public void Setclassid (String classID) {this.classid=classid; }}
See attachment, Supplemental Mylist.java content, submit run Results (fullscreen) lesson push code to Code cloud public class MyList {public static void main (String [] args) {//Choose appropriate construction method, Use the number of the two students before and after the study number to create four nodes//to connect the above four nodes into a single linked list without a head node//traverse a single linked list, print each node//insert yourself into the appropriate position (study number Ascending)//Traverse single linked list, print each node//from the linked list to delete itself//Traverse single linked list, Print each node's}}public class node<t> //single-linked list node class, T specifies the node's element type {public T data; Data fields, storing data elements public node<t> next; Address field, referencing the successor node public node (T data, node<t> next) //construct node, data specify the element, next specify subsequent node { This.data = data ; T object reference Assignment This.next = next; Node<t> object reference Assignment } public Node () {This (null, NULL); } public string toString () //Returns the description string of the node data field { return this.data.toString ();} }
20165234 Tenth week of Java programming