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 #(phoneNumber), and two abstract methods: a boolean-valued method named createConnection that returns a boolean and accepts an reference to an object of type Network, and a void-returning method, closeConnection, that accepts no parameters

LANGUAGE: JAVA

CHALLENGE:

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 #(phoneNumber), and two abstract methods: a boolean-valued method named createConnection that returns a boolean and accepts an reference to an object of type Network, and a void-returning method, closeConnection, that accepts no parameters

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

1 Comment

  1. j p on August 8, 2017 at 1:07 am

    This is the code that worked:

    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();
    }

Leave a Comment

You must be logged in to post a comment.