JMU
Design of the JMUPhoneNumber Class


1 Introduction

The JMUPhoneNumber class is an encapsulation of a telephone number at James Madison University.

2 Details

The initial design of the JMUPhoneNumber class is summarized in the following UML class diagram.
JMUPhoneNumber.png

Other details are provided below.

2.1 Constants

This class must, at a minimum, contain the following public constants:
    public static final int   US_OLD = 0;
    public static final int   US_NEW = 1;
    public static final int   EUROPE = 2;
    public static final int   JMU    = 3;

    public static final int   OFFICE = 568;
    public static final int   DORM   = 612;
  

2.2 Attributes

This class must, at a minimum, contain the following private attributes:

    areaCode - An int containing the area code.
    exchange - An int containing the three-digit exchange (i.e., 568 for offices or 612 for dormitories).
    extension - An int containing the extension (i.e., the last four digits of the phone number).
    format - An int containing the format to be used by the toString method.

It may contain other attributes as well.

2.3 The Default Constructor

    /**
     * Default Constructor.
     *
     * Constructs a JMUPhoneNumber with the areaCode set to 540,
     * the exchange set to 568, the extension set to 6211, and the
     * format set to JMU
     */
    public JMUPhoneNumber()
    {

    }
  

2.4 The isDorm() Method

    /**
     * Checks if this JMUPhoneNumber is in a dorm.
     *
     * @return   true if in a dorm and false otherwise
     */
    public boolean isDorm()
    {

    }
  

2.5 The isOffice() Method

    /**
     * Checks if this JMUPhoneNumber is in an office.
     *
     * @return   true if in an office and false otherwise
     */
    public boolean isOffice()
    {

    }
  

2.6 The setExchange() Method

    /**
     * Sets the exchange associated with this JMUPhoneNumber.
     *
     * Note: If the parameter is not valid this method sets the
     *       exchange to OFFICE
     *
     * @param  exchange   The exchange (either OFFICE or DORM)
     */
    public void setExchange(int exchange)
    {

    }
  

2.7 The setExtension() Method

    /**
     * Sets the extension associated with this JMUPhoneNumber.
     *
     * Note: If the parameter is not valid this method sets the
     *       extension to 6211
     *
     * @param  extension   The extension (between 0000 and 9999)
     */
    public void setExtension(int extension)
    {

    }
  

2.8 The setFormat() Method

    /**
     * Sets the format to be used by the toString method.
     *
     * The valid formats along with examples are:
     *
     *    US_OLD   (540) 568-6211
     *    US_NEW   540-568-6211
     *    EUROPE    540.568.6211
     *    JMU       x8-6211
     *
     * Note: If the parameter is not valid this method sets the
     *       format to JMU
     *
     * @param  format   A valid format
     */
    public void setFormat(int format)
    {

    }
  

2.9 The toString() Method

    /**
     * Returns a formatted String representation of this JMUPhoneNumber
     * (see the discussion of the setFormat method).
     *
     */
    public String toString()
    {

    }
  

Copyright 2017