farrell2k's Profile User Rating: -----

Reputation: 841 Master
Group:
Expert
Active Posts:
2,575 (2.24 per day)
Joined:
29-July 11
Profile Views:
27,412
Last Active:
User is offline Today, 03:39 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Hyundai
Dream Kudos:
225
Expert In:
Java

Latest Visitors

Icon   farrell2k has not set their status

Posts I've Made

  1. In Topic: perform an action only if a certain amount of time has passed

    Posted 18 Sep 2014

    Timer is still the right too, the Uilt timer that is, but does this make sense?

    int rate = 17;
    int timesVvalueIsTheSame;
    int counter;
    int currentValue = object.getValue();
    
        while(dataIncoming) {
            ++counter;
            int value = object.getValue();
            
            if (value == currentValue) {
                ++timesValueIsTheSame;
            }
    
            if (counter == (rate * 3)  && timesValueIsTheSame == 3) { // 3 seconds has gone by.
                executeDesiredMethod();        
            }
            currentValue = value; 
            
            Thread.sleep(rate);
        }
    
    
  2. In Topic: JAVA Platform Game Jumping and collision

    Posted 16 Sep 2014

    I didn't read your code, but unless Mario is jumping, you should always have gravity pulling him down when he is not touching the ground.

    if (!jumping && !onGround) {
        Mario.y += gravity;
    }
    
    
  3. In Topic: Highest of Three Grades

    Posted 16 Sep 2014

    You should never do input this way for users. They could enter 4 numbers and your math would be wrong.
  4. In Topic: Highest of Three Grades

    Posted 15 Sep 2014

    You need to do what I mentioned previously, grab input as one long String of grades, split it up, then convert the Strings to numbers. It's not hard, but if you need an explanation on anything, just say so. I think you are probably familiar with most of this this stuff, save for maybe that for loop, which is called the enhanced for loop, a bit of syntactic sugar, and maybe String.split, which just splits a String into pieces based on the specified delimiter, in this case " " (space), and puts them into a String[] array. Integer.parseInt() will convert a String representation of a number into a proper number.

    public static void main(String[] args) {
            int gradesSum = 0;
            
            System.out.println("Enter grades");
            String inputLine = new Scanner(System.in).nextLine();
            String[] grades = inputLine.split(" ");
            for (String grade : grades) {
                try {
                    gradesSum += Integer.parseInt(grade);
                } catch (NumberFormatException e) {
                    System.out.println("YOu did not enter a number, or otherwise screwed up!");
                }
            }
            
            /*
            Now you take gradesSum and do your calculations.  If you need to know how many grades were input, you can get   that           from grades.length.
            */
            System.out.println(gradesSum);
            
        }
    
    
  5. In Topic: Highest of Three Grades

    Posted 15 Sep 2014

    I am under the impression that he wants to have a user enter: 45 90 65 87, then enter, which makes much more sense than having to press enter after each one.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Years Programming:
4
Programming Languages:
Java, but willing to deal with C#

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    grizrule Icon

    11 Jun 2014 - 22:08
    Hey, I know who you are, hail Sithis.
Page 1 of 1