CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2015
    Posts
    1

    Question Help with Java - Beginner

    I have an assignment that asks the following. If someone could give me some guidance it would be much appreciated. I have never programmed so I don't even know where to start. The assignment reads:
    Take a class called seriaf.poo.server.config.Server Config (serial.poo.server.config is the package name) whose role reading from a file configuration parameters, which we will use later in the application server . This class must meet the following constraints:
    Class must have two constructors:
    One with a String argument that represents the configuration file read
    One without arguments, which will consider the default configuration file as server.conf.
    ServerConfig type objects must read the configuration file and then read the file to expose parameters methods.
    Builders ServerConfig class should throw exceptions if problems reading or interpretation of the configuration file:
    java.io.IOException if the specified file does not exist or can not read (the exception is thrown by methods that belong to classes of stream type, so it is not necessary than throwing it on).
    seriaf.poo.server.exceptions.InvalidFormatException if at least one line of the file does not match expected (this exception does not exist and will be created).
    seriaf.poo.server.exceptions.UnknownKeyException if there configured in a proprietary file known (this exception does not exist and will be created).
    seriaf.poo.server.exceptions.MissingKeyException if the file is missing one of the expected properties (this exception does not exist and will be created).
    Class must be immutable.
    The following properties are only valid ones, which must be in the configuration file:
    TCP_PORT - is the TCP port on which the server is configured to accept connections and can be read from objects of type int getTcpPort ServerConfig method ()
    MAX_CLIENTS - the maximum number of clients per server can serve, and that can be read from objects of type int getMaxClients ServerConfig method ()
    Perform a test for this class (which is to read a file and the display of readings) which placed him in class main method Main.
    The configuration file is ServerConfig class read a text file, consisting of lines of the following form:
    PROPERTY = value
    Any line starting with the # character, followed or not by spaces or characters "tab" is considered as comment and not taken into account.
    Lines in the file that do not contain any printable character, but spaces and / or tabs are not taken into account.
    No account is taken of spaces (or tabs) at the beginning or end of the line.
    An example configuration file:
    #this is a comment line
    ******# Another comment line is this, Which shouldnt BE ignored, FOLLOWED by a line with spaces, That shouldnt Also ignored BE
    *
    MAX_CLIENTS = 100
    *******TCP_PORT = 9000

    Notes:
    The three exceptions were to be defined very simple implementations. It should be defined as some classes that extend the Exception class, and no need contain only the definition of a constructor with a String argument that does is to call the superclass constructor.
    The files will be handed over Java implementations of the following classes: ServerConfig, Main, Message, PrivateMessage, InvalidFormatException, UnknownKeyException and MissingKeyException.
    The following classes and methods can be useful in homework. Find them in the API documentation:
    String.trim
    String.charAt
    String.contains
    String.startsWith
    String.equals
    String.split
    Integer.parseInt
    BufferedReader.readLine
    Because you can have two different String objects (with different references) but containing the same text, and the operator == compares the references, the right way which compares two strings is by calling equals:
    String a = "abc";
    String b = new String (a);
    if (a == b) {// <- Incorrect assessment will return false
    **// ...
    }
    if (a.equals (b)) {// <- correctly assessing returns true
    **// ...
    }

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Help with Java - Beginner

    If you have never programmed, this assignment looks like it's probably too much for a beginner.
    It's usually better to start with simpler programs to learn how to program before trying something as complex as this.

    Break the full assignment up into smaller, simpler projects, write the code for each separately, fix the problems to get it to work and move through the projects one by one. When they are all done, work on fitting what you learned into a single program.
    Norm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured