Arvutiteaduse instituut
  1. Kursused
  2. 2017/18 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (P2NC.01.083)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2017/18 kevad

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links

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 of String 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.

  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused