Question: //The Code public class Skater { private String name; private String state; private double time; public Skater(String name, String state, double time) { super(); this.name

//The Code//The Code public class Skater { private String name; private String state;private double time; public Skater(String name, String state, double time) { super();

public class Skater {

private String name; private String state; private double time; public Skater(String name, String state, double time) { super(); this.name = name; this.state = state; this.time = time; }

public String getName() { return name; }

public String getState() { return state; }

public double getTime() { return time; }

public void setTime(double time) { this.time = time; }

@Override public String toString() { return name + " " + state + " " + time; } }

public class SkateRace { private Skater skaters[]; private int size = 0;

public SkateRace(int numberOfSkaters) { skaters = new Skater[numberOfSkaters]; } public int getSize() { return this.size; } public int getLength() { return skaters.length; } public void addSkater(Skater skater) { skaters[size++] = skater; sortSkaters(); } public Skater getSkater(String name) { for (int i=0; i

/** * Since the array is sorted at any point of time, * we are just simply at the given index * * @param position * @return */ public Skater getSkater(int position) { if (position>=0 && position secondTime) { skaters[i].setTime(secondTime); sortSkaters(); return true; } } return false; } public void removeSkater(String name) { for (int i=0; i

import java.util.Scanner;

public class RaceDriver { public void phaseOne(Scanner stdIn, SkateRace sRace) { System.out.println(" Starting First Phase "); System.out.println("Enter Skaters data as : Name State Time "); for (int i=0; i

System.out.println(" Current standings : "); System.out.println(sRace.toString()); } public void phaseTwo(Scanner stdIn, SkateRace sRace) { System.out.println(" Starting Second Phase "); while (true) { System.out.print("Enter the name and updated time of the skater you want to update or 'quit' : "); String inputLine = stdIn.nextLine().trim(); String[] inputData = inputLine.split(" "); if (inputLine.equalsIgnoreCase("quit")) { break; } if (! sRace.updateSkater(inputData[0], Double.parseDouble(inputData[1]))) { System.out.println("Skater "+inputData[0] + " not update "); continue; } System.out.println("Skater "+inputData[0] + " is update and the new data is ["+sRace.getSkater(inputData[0]).toString()+"] "); System.out.println("Current Leader : "+findLeader(sRace)); } System.out.println(" Current standings : "); System.out.println(sRace.toString()); } public void phaseThree(Scanner stdIn, SkateRace sRace) { System.out.println(" Starting Third Phase "); while (true) { System.out.print("Enter the name of the skater you want to disqualify or 'quit' :"); String inputLine = stdIn.nextLine(); if (inputLine.equalsIgnoreCase("quit")) { break; } sRace.removeSkater(inputLine); System.out.println("Current Leader : "+findLeader(sRace)); } System.out.println(" Final standings : "); System.out.println(sRace.toString()); } public Skater findLeader(SkateRace srace) { return srace.getSkater(0); } public static void main(String args[]) { System.out.print("Please enter how many Skater you want to enter : "); Scanner scanner = new Scanner(System.in); int numOfPlayers = scanner.nextInt(); SkateRace sRace = new SkateRace(numOfPlayers); RaceDriver raceDriver = new RaceDriver();

System.out.println(" Welcome to Skate Race Program "); raceDriver.phaseOne(new Scanner(System.in), sRace); raceDriver.phaseTwo(new Scanner(System.in), sRace); raceDriver.phaseThree(new Scanner(System.in), sRace); scanner.close(); } }

What to do In this assignment, you will continue working on Assignment 6 by adding some features. You have to add a new member method to SkateRace class printStandings(): void that will print the array of skaters in ascending order (sorted) by race time. Use insertion sort for this. Your printstandings method should call a helper method that does the sorting. The signature of the helper method should be private void sort Skater array) What to do In this assignment, you will continue working on Assignment 6 by adding some features. You have to add a new member method to SkateRace class printStandings(): void that will print the array of skaters in ascending order (sorted) by race time. Use insertion sort for this. Your printstandings method should call a helper method that does the sorting. The signature of the helper method should be private void sort Skater array)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!