Task 1. Telephone
Create an abstract class called Telephone
which has private instance fields for the telephone number (String
) and the buzz (String
). The class has at least the following methods:
- non-abstract
get
methods which return the values of the corresponding instance fields; - an abstract method called
importantInfo
which returns data ofString
type; - a constructor which instantiates the instance fields;
- a method with the following signature
String lastNumbers(int n)
; the method returns n last digits of the telephone number.
Create a non-abstract class called DeskTelephone
which is subclass of Telephone
class. The constructor of DeskTelephone
class instantiated the location (String
) in addition to the telephone number and the buzz. The method importantInfo
has to be overridden so that it returns the location of the telephone.
Create a non-abstract class called MobilePhone
which is subclass of Telephone
class. The constructor of MobilePhone
class instantiated the name of the owner (String
) and the functionality to take pictures (boolean
) in addition to the telephone number and the buzz. The method importantInfo
has to be overridden so that it returns the name of the owner.
Update Telephone
so that it implements Comparable<Telephone>
interface. The comparison must be based on the last three digits of the telephone number (int
).
Override toString
method in DeskTelephone
and MobilePhone
classes so that all the information about the telephone would be printed out. Output information about each telephone.
Create the main class. Create an array of different telephones and sort the array using java.util.Arrays.sort(Object[] o)
method.