Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to return an alert true if the server is functioning normally

  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool how to return an alert true if the server is functioning normally

    So, I don't know how to start off this program. I'm not looking for the final answer, but I don't know two things: 1. the objective, 2. what type of thing do I start it off with? A method? I'm pretty sure it's not a class right because it already has a class?

     
    public class WebFarm 
    { 
      private ArrayList<Server> servers; 
     
      /* constructors and other methods and instance variables not shown */ 
    } 
     
    public class Server 
    { 
      public String ipAddress() { /* implementation not shown */ } 
     
      public boolean ping() { /* implementation not shown */ } 
     
      /* constructors and other methods and instance variables not shown */ 
    }

    the Instructions:

    The ping() method of the Server class returns true if the server is currently functioning normally; otherwise it returns false. Write a definition for the needsAttention() method of WebFarm that returns an ArrayList containing the servers that are not functioning normally:

     
    public ArrayList<Server> needsAttention() 
    { 
     
    //I can put code here
     
    }

    Again, I don't know how to start off the code. If anyone could give me enough info that I could put something to edit and work off of, I'd love that. Thanks.


  2. #2
    Junior Member
    Join Date
    Feb 2014
    Location
    Finland
    Posts
    25
    My Mood
    Bored
    Thanks
    3
    Thanked 5 Times in 5 Posts

    Default Re: how to return an alert true if the server is functioning normally

    Hello.

    Well this sounds alot like a typical school exercise.

    So your goal is to make the implementation of the needsAttention() method. Since so little of the inner workings are given, you have to assume that the WebFarm's servers -array list contains a list of
    Server class instances that you have to run through, ping each and return a list of those of which returned false.

    In all simplicity, in pseudo code, something like this:

    public ArrayList<Server> needsAttention() 
    { 
    make a list to store the failed servers
    loop trough the server instances {
       if ( currentServer.ping() == false ) {
           add currentServer to failedServersList }
    return failedServers
    }
     
    }

    So thats the idea. Dont know why the ipAddress -method is given. Maybe it is to be used in a later example? Anyhow, hope you got the drift and good luck with the homework

  3. #3
    Member
    Join Date
    Aug 2013
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to return an alert true if the server is functioning normally

    Does that mean like this?

    for (int i = 0; i < Server.length()-1; i++){
     
        if ( currentServer.ping() == false ) {
     
        add currentServer to failedServersList; 
     
    }
     
        return failedServers;
     
    }

Similar Threads

  1. Replies: 2
    Last Post: September 16th, 2013, 03:32 PM
  2. alert box in front end to display errors in backend
    By nischalinn in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: July 24th, 2012, 11:16 PM
  3. Warning! Greenhorn alert
    By Montrell79 in forum Member Introductions
    Replies: 2
    Last Post: March 6th, 2012, 03:56 AM
  4. Basic Applet Not Functioning Correctly
    By AlexAndAHalf in forum Java Applets
    Replies: 4
    Last Post: December 7th, 2011, 09:33 AM
  5. Threading not functioning
    By feonx in forum AWT / Java Swing
    Replies: 1
    Last Post: October 31st, 2011, 02:56 PM

Tags for this Thread