cz.muni.fi.pb162.task2
Class MobilePhone

java.lang.Object
  extended by cz.muni.fi.pb162.task2.MobilePhone
All Implemented Interfaces:
cz.muni.fi.pb162.task2.Chargeable, cz.muni.fi.pb162.task2.Phone

public class MobilePhone
extends java.lang.Object
implements cz.muni.fi.pb162.task2.Phone, cz.muni.fi.pb162.task2.Chargeable

Version:
20 10 2009
Author:
Tomas Sedmik

Constructor Summary
MobilePhone()
          Default contructor
MobilePhone(int charge)
          Constructor
 
Method Summary
 java.lang.String connectedNumber()
          Returns currently called number.
 void dial(java.lang.String number)
          Dials the number, starts the call.
 int discharge()
          Discharging step.
 int getBatteryState()
          Returns current battery charge (state).
 void hangUp()
          Hangs up the phone.
 int charge()
          Charging step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MobilePhone

public MobilePhone()
Default contructor


MobilePhone

public MobilePhone(int charge)
Constructor

Parameters:
charge - represent amount of charge which's in the device
Method Detail

connectedNumber

public java.lang.String connectedNumber()
Returns currently called number.

Specified by:
connectedNumber in interface cz.muni.fi.pb162.task2.Phone
Returns:
currently called number during the call (phone conversation), null if the phone is hang up (nobody is connected).

dial

public void dial(java.lang.String number)
Dials the number, starts the call.

Specified by:
dial in interface cz.muni.fi.pb162.task2.Phone
Parameters:
number - called number

discharge

public int discharge()
Discharging step. Decreases the battery state by 1. If the battery is fully discharged, nothing happens.

Specified by:
discharge in interface cz.muni.fi.pb162.task2.Chargeable
Returns:
battery state after the discharging step in the range 0-100

getBatteryState

public int getBatteryState()
Returns current battery charge (state).

Specified by:
getBatteryState in interface cz.muni.fi.pb162.task2.Chargeable
Returns:
battery charge in the rage 0-100 (0 = discharged, 100 = fully charged)

hangUp

public void hangUp()
Hangs up the phone.

Specified by:
hangUp in interface cz.muni.fi.pb162.task2.Phone

charge

public int charge()
Charging step. Increases the battery state by 1. If the battery is fully charged, nothing happens.

Specified by:
charge in interface cz.muni.fi.pb162.task2.Chargeable
Returns:
battery state after the charging step in the range 0-100