Programming Project 1269140642
Project ID: 1269222872
Project Details
  • Status:
    Closed (Chosen Programmer: eperfections; Paid; Rated 10 out of 10)
  • Posted:
    3/21/2010 at 21:54 EST
  • Closed:
    3/21/2010 at 22:52 EST
  • Project Creator:
    Rated 10 out of 10 for this project.
  • Budget:
    N/A
  • Description:
    Comments are REQUIRED

    Directions


    The file must be called <YourNameProg1.java> (driver program)
    IpAddress.java (IP Address class file)

    Example: JohnDoeProg1.java (driver program)
    IpAddress.java (stores IP address as an array of four octet int's.

    Ensure you include ALL files required to make your program compile and run.I would like to see your .java files only.

    Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.


    Overall Requirements

    Every computer on the Internet has a unique identifying number, called an Internet protocol (IP) address. To contact a computer on the Internet, you send a message to the computer's IP address. Here are some typical IP addresses:

    216.27.6.136
    224.0.118.62

    There are different formats for displaying IP addresses, but the most common format is the dotted decimal format. The above two IP addresses use the dotted-decimal format. It's called “dotted” because dots are used to split up the big IP address number into four smaller numbers. It's called “decimal” because decimal numbers are used (as opposed to binary) for the four smaller numbers.

    Each of the four smaller numbers is called an octet because each number represents eight bits (oct means eight). For example, the 216 octet represents 11011000 and the 27 octet represents 00011011.

    YourNameProg1.java

    Your driver class should contain the following main method:

    public static void main(String[] args)
    {
    IpAddress ip = new IpAddress("216.27.6.136");
    System.out.println(ip.getDottedDecimal());

    System.out.println(ip.getOctet(4));

    System.out.println(ip.getOctet(1));

    System.out.println(ip.getOctet(3));

    System.out.println(ip.getOctet(2));

    } // end main

    IpAddress.java

    Implement an IpAddress class that stores an IP address as a dotted-decimal string and as four octet int's. (8 points)

    You must implement all of the following:

    Instance variables:
    dottedDecimal – a dotted-decimal string. Example value: "216.27.6.136"

    firstOctet, secondOctet, thirdOctet, fourthOctet – four int variables that store the octets for an IP address

    Constructor:
    This constructor receives one parameter, a dotted-decimal string. You may assume that the parameter's value is valid (i.e., no error checking required). The constructor initializes the instance variables with appropriate values. There are many ways to solve the problem of extracting octets from the given dotted-decimal string. We recommend that you use String methods to extract the individual octets as strings, and then use parseInt method calls to convert the octet strings to int's.

    getDottedDecimal method:
    This is a standard accessor method that simply returns the dottedDecimal instance variable's value.

    getOctet method:
    This method receives the position of one of the octets (1, 2, 3, or 4) and returns the octet that's at that position.

    Sample Session:

    When using the main method specified above, your output should be:

    216.27.6.136

    136
    216
    6
    27
  • Tags:
Project Bids



(5 bids have been placed. rowdy14life has chosen to keep all bids for this project hidden.)