9.2k views
3 votes
All phones must have a way of making and then terminating a connection to the phone network; however the exact procedure for doing so depends upon the nature of the phone (e.g. landline, cell phone, satellite phone). Write a abstract class, Phone, that contains a string instance variable, phoneNumber, a constructor that accepts a string parameter initializing the instance variable, an accessor method, getPhoneNumber, that returns the phoneNumber, a toString method that return the phoneNumber in the form

1 Answer

2 votes

Answer:

The code will be a java-script code

Step-by-step explanation:

public abstract class Phone{

private String phoneNumber ;

public Phone (String thePhoneNumber) {

phoneNumber = thePhoneNumber ;

}

public String getPhoneNumber ( ) {

return phoneNumber ;

}

public String toString ( ) {

phoneNumber = "# (" + phoneNumber + ") " ;

return phoneNumber ;

}

public abstract boolean createConnection (Network status) ;

public abstract void closeConnection( ) ;

}

User Andrew Johns
by
8.0k points