Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java polymorphism and inheritance Task: Create an interface named Comparison whose method can be used to compare two Time objects. The methods will include isGreater,

Java polymorphism and inheritance  Task: Create an interface named Comparison whose method can be used to compare two Time objects. The methods will include isGreater, isLess, and isEqual. Create another class that will implement these methods. (Compare two time objects, inputted by the user) *Fix my code *Add comments  Source Code: import java.util.*; interface Comparison { boolean isGreater(Time x, Time y); boolean isLess(Time x,Time y); boolean isEqual(Time x, Time y); } public class Time implements Comparison { int am, pm; public boolean isGreater(Time x, Time y) { if (am > pm) { System.out.print("True"); } else System.out.print("False"); } public boolean isLess(Time x,Time y) { if (am < pm) { System.out.print("True"); } else System.out.print("False"); } public boolean isEqual(Time x, Time y) { } } public class Main { public static void main(String[] args) { System.out.println("Enter your first number: "); int x = new Time(); System.out.println("Enter your second number: "); int y = new Time(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions