Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need the full written java code for this java assignment. Please help me write the code according to the UML diagrams with the correct
I need the full written java code for this java assignment. Please help me write the code according to the UML diagrams with the correct classes, variables and methods. Should have 3 classes: country, diving and main and has the output shown in the diagrams. If possible please use the most basic methods. Thanks a lot.
Objectives - Selection and Repetition control structures - Classes and objects - Instance and static methods - The use of arrays and ArrayList's A lot of us may wonder how they come up with the scores for a diving competition. It takes several steps to get from the judge ratings to the final scores, and the announcers are rarely eager to explain it. Each judge rates the dive from 0 ("completely failed") to 10 ("excellent"). This is based on how well the diver performs, from his starting position to entry into the water. The judges do not take difficulty into account for this score. - Example: a diver receives execution scores of 6.5, 7.0, 7.0, 7.5, 7.5, 8.0, and 8.0. Note that the score is either .0 or .5( is from 0 to 10), maximum is 10.0 Cross out the outliers: So cross out two scores on each end: 6.5,7.0,7.0,7.5,7.5,8.0, and 8.0, i.e., remove the two top and two bottom scores Add the rest together. Find the sum of the remaining scores. -Example: 7.0+7.5+7.5=22.0 Multiply by the degree of difficulty (DD). Each attempted dive has a degree of difficulty calculated in advance. This is based on many factors, such as the number of twists and somersaults and the take-off and entry positions. Multiply your last sum by the degree of difficulty to get the final score for this dive. - Example: Let's say the diver attempted an inward 21/2 somersault dive in the 10 meters competition, in the pike position. This has a difficulty score of 2.8. Multiply this by the execution score to get the final score: 22.0x 2.8= 61.6. Note that the degree of difficulty has only one decimal point, i.e., *.\# (* is 1,2,3,4, very seldom 5 , \# is 0 to 9 ). In a competition, divers need to dive a few rounds, normally 5 rounds. The degrees of difficulty, for each round, are usually pre-determined before the beginning of the competition. Let us look at a simple UML diagram for this assignment: Two important classes: Country class, Diving class; and a main class that we will define it later. Convenient to your design, additional class(es) is / are allowed. Let us now look at the detail of each class. Basically each class has private instance variables, constructors, accessor methods, mutator methods and some other methods Usually a player participates in a diving competition, he / she needs to declare the level of diving difficulties before the competition. The competition usually consists of 5 rounds. This array stores 5 real number representing the degree of difficulties of each round. The displayInfo method displays the info of a participant, for example, Thailand Name 2 152.12.52.64.4 4.5 Note that this array (dArray) is "pre" sorted before comstructing a Country object. Next, let us look at the Diving class which is the most important class of this assignment: This class has a constant SIZE indicating the number of judges, usually is 7 . It consists of 5 instance variables: name (a Country object), score (an array, scores given by judges), difficulty (level of difficuly of each dive), cf (carried forward derived from the previous round, obviously round 1 has no carried forward score, i.e. 0 and fs (the final score of the current round). Most of the methods are obvious in definition. The getsortedList stores the stores the scores in a list (a dummy list) and sort it; you can use it to retrieve the highest, second highest etc. scores. This method is optional, you can find your own way to solve the problem. The display info method displays the result of a participant according to the following format: (you will see order of printing during the runtime interactions and displays): Thailand 0.5 8.0 3.5 0.59.00.58.0 2. 1 0.00 25.20 25.20 Now our main class to drive the whole application. Let us look at the UML diagram: We define a constant to store the number of rounds for a competition. I may ask you to change the value of this constant during demo; just make sure that you produce a general design. We define a string array of countries (Countries) to be used in the design. A country can send more than one participant. We usually use, for example, China 1, China 2 if China sends two participants. A few important tasks to be done in the main class. Let us look at the runtime interactions and display before we look the methods used in the main class: Upon execution, the system firstly displays the information of each participant: Now, the display of round 1 : Followed by the ranking of round 1 : Some notes to round 1 (and hence for each round), the level of difficulties is extracted from the array of difficulties (i.e., dArray) and the result of each round is sorted. I will show you my way of sorting even we did not cover any sorting topics in lessons 0 . Also note that the carried forward score for each participant is 0.00 as we are in round 1; and round 2 onward will copy the total scores obtained from the previous round to the carried forward score; and we will use an array to store the carried forward scores for all the participants. Now look at the interactions and display of round 2 : The ranking for round 2 : Note that the starting positions for each round remain unchanged except participants have different degree of difficulties. If you look at the degree of difficulties in round 2 for each of the participant, actually they are listed under the column D 2 (see page 5). Let you see one round, round 3: The result after round 3 : Your system must continue the number rounds according to a constant specified in the main class, i.e., NO_ROUNDS. Now let me tell you how I designed this system. Note that you can have your own idea in doing this assignment provided you use the two specified classes to achieve the same target. Let us look at the methods in the following UML diagram: - getscore method receives an array score as parameter and update the scores for all the judges - getCountry method receives two parameters, a list of Diving objects and a value of the final result; determines and returns the name of the country that has the given result. Of course, a few countries may have the same result, you just return any one of them. You can do some more refinements for uniqueness, to me, is optional, you will not be penalized with this minor logical error. - displaysortedList receives a list of diving objects and display the sorted results. - getDifficuly generates and returns a real number in between 2.0 to 5.0 with only one decimal digit. - getDArray constructs and returns an array of degree of difficulties for a participantStep by Step Solution
There are 3 Steps involved in it
Step: 1
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