Results 1 to 2 of 2
  1. #1
    martineze is offline Member
    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Default Help Please on basic concepts over the phone

    Hello will someone in the United States help me to understand basic concepts. I think I would understand Java if someone told me exactly how the program executes step by step with the methods and constructor, etc. I can call you if you live in the United States.

    Here is a simple program...

    5.2
    All start off with a definition/ explanation of the class. Then below have the categories field summary, constructor summary, and method summary with brief summaries of how they are utilized in the class. Below this are the methods that are inherited from other classes and their link to their explanation detail on what they do. After this it then has the details in the category of Field Detail, Constructor Detail, and Method Detail with a more indebt explanation of the topics that include parameters and returns used in these. It is kind of like an encyclopedia of each class for developers to utilize with explanations of all the classes’ methods.

    5.3
    Both these methods, startsWith, test to see if the string starts with a specified prefix (a, b, and c for example). The difference between them is one has a parameter of toffset which it tells where to start looking in the string. The one that does not have a toffset parameter begins looking at the beginning of the string.
    5.4
    The method endsWith tests whether a string ends with a given suffix. The parameter would be of course String and then what you are looking for. This method returns true if the parameter is found and false if it is not.
    5.5 and 5.6 on p. 127
    There is a method that returns the number of characters in a string it is called length() and it has no parameters.

    I found these methods by reading every methods’ short definition on what it does under the class String. I think it is not to hard to find them, you need to look under the right class though, so think of it as in encyclopedia.



    5.14
    import java.util.ArrayList;
    import java.util.Random;
    /**
    * Write a description of class RandomTester here.
    *
    * @author ()
    * @version (Exercise 5.14 p.132)
    */
    public class RandomTester
    {

    Random randomGenerator;
    int index;

    /**
    * Constructor for objects of class RandomTester
    */
    public RandomTester()
    {
    // initialise instance variables
    randomGenerator = new Random();



    }
    public void printOneRandom()
    {
    index = randomGenerator.nextInt();
    System.out.println(index);

    }

    public void printMultiRandom(int howmany)
    {
    while (howmany != 0)
    {
    index = randomGenerator.nextInt();
    System.out.println(index);
    howmany--;

    }


    }
    }

    5.16
    public void throwDiceOnce()
    {
    index = 1 + randomGenerator.nextInt(6);
    System.out.println(index);

    }

    public void throwDiceMulti(int howmany)
    {
    while (howmany != 0)
    {
    index = 1 + randomGenerator.nextInt(6);
    System.out.println(index);
    howmany--;

    }


    }

    5.1
    public String getResponce()
    {


    switch (index = 1 + randomGenerator.nextInt(3))
    {
    case 1:
    responce="yes";
    break;
    case 2:
    responce="no";
    break;
    case 3:
    responce="maybe";
    break;
    }

    return responce;
    }


    5.19, and 5.20 -- then submit your completed RandomTester class
    public void changeMaxOnce(int max)
    {
    index = 1 + randomGenerator.nextInt(max);
    System.out.println(index);

    }



    public void changeMaxMinOnce(int max, int min)
    {
    index = min + randomGenerator.nextInt(max);
    while (index > max)
    {
    index = min + randomGenerator.nextInt(max);
    }
    System.out.println(index);

    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,701
    Rep Power
    8

    Default Re: Help Please on basic concepts over the phone

    What you're asking for is a private tutor at best, and at worst somebody to do your homework for you. Neither are cheap.

    Instead, how about you ask a specific technical question (in the form of an SSCCE, with code tags) and we'll be happy to help for free?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 0
    Last Post: 06-06-2012, 08:26 AM
  2. Basic OOP concepts and array of objects help.
    By dschm42 in forum New To Java
    Replies: 5
    Last Post: 04-24-2011, 07:38 AM
  3. Concepts escaping me?!
    By skatefreak in forum New To Java
    Replies: 2
    Last Post: 04-29-2009, 02:36 PM

Posting Permissions

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