Question: package practicePackage.classesObjects.attempts.Stage1; public class CarTrip { public double distance, time; //in kms and hours respectively /** * * @param d: value meant for distance *

package practicePackage.classesObjects.attempts.Stage1;

public class CarTrip { public double distance, time; //in kms and hours respectively /** * * @param d: value meant for distance * @param t: value meant for time * * assign the higher of 0 and d into distance * assign the higher of 0 and t into time */ public CarTrip(double d, double t) { //to be completed } public double averageSpeed() { return 0; //to be completed } /** * return details in the format "distance kms travelled in time hours" * For example, if distance = 2.5, time = 1.2, return "2.5 kms travelled in 1.2 hours" */ public String toString() { return ""; //to be completed } /** * * @param other * @return 1 if calling object distance is more than parameter object distance * -1 if calling object distance is less than parameter object distance * 0 if calling object distance is equal to parameter object distance */ public int compareTo(CarTrip other) { return 0; //to be completed } }

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!