Flukeshot's Profile User Rating: *****

Reputation: 415 Architect
Group:
Contributors
Active Posts:
1,027 (1.67 per day)
Joined:
14-November 12
Profile Views:
9,368
Last Active:
User is offline Jun 21 2014 02:36 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Honda
Dream Kudos:
50

Latest Visitors

Icon   Flukeshot is back to relatively high activity

Posts I've Made

  1. In Topic: Help me find the functional interface

    Posted 20 May 2014

    This is a wild guess, but based on the correct use of .addActionListener is ( e -> /*insert method or code body here*/ );

    I would suggest the correct use of your example would be evaluator.setQuitAction( action -> isLooping = false );
  2. In Topic: Trying to assign random numbers to a deck of cards

    Posted 15 May 2014

    You seriously need to considder better variable names than this..

    Random is probably going to be spitting out duplicate numbers. Try something like this:

    import java.util.Random;
    
    public class Hokm {
    	
    	Random r = new Random();
    	int[] usedNumbers = new int[52];
    	
    	void generate52UniqueRandomNumbers() {
    		
    		for(int i = 0; i < usedNumbers.length; i++) { // iterate over the array index
    			
    			int thisPass = r.nextInt(52)+1; // create a random number
    			
    			for(int j : usedNumbers) { // iterate over the array
    				
    				if(j==thisPass) continue; // check this random number is not already present
    			}
    			
    			usedNumbers[i] = thisPass; // we will only reach this line if we have a unique number
    		}
    	}
    	
    	public static void main(String[] args) {
    		
    		new Hokm().generate52UniqueRandomNumbers();
    	}
    }
    
  3. In Topic: MVC help?

    Posted 15 May 2014

    Anything GUI-related (including buttons) go in the view class. Anything related to storing data goes into your model class and anything to do with changing the data or the gui components goes into your controller class.

    The main reason for the MVC pattern is to decouple your GUI from your main program. So the first step would be to create a program that does not require a GUI, then build one that can send the signals through the controller to 'read/write' data from the model.
  4. In Topic: I need help with methods involving loops

    Posted 15 May 2014

    Well, if you think about it, within that loop the variable 'd' will remain referenced to one object. This will simply repeat the one display text n times. Is that what you wanted?
    Otherwise you would need a Collection or array of them passed into the method.
  5. In Topic: I need help with methods involving loops

    Posted 14 May 2014

    You've got it inside out :) A method can only return once. What you need to do is perhaps have a collection of displayables and call displayText() on them.

    Displayable[] collection = generateDisplayables(); // let's assume this creates an array of 20 displayables
    for(int i = 0; i < collection.length; i++) { // loop until end of collection
       collection[i].getDisplayText();
    }
    

My Information

Member Title:
A little too OCD
Age:
25 years old
Birthday:
February 10, 1989
Gender:
Location:
Waterford, Ireland
Years Programming:
6
Programming Languages:
I know a lot of: Java
I know a enough of: Visual Basic, LUA
I know a little of C, C++, C#

--MarkupLanguages--
XML, HTML

Contact Information

E-mail:
Private

Friends

Showing 50 random friends of 18

Comments

Page 1 of 1
  1. Photo

    farrell2k Icon

    08 Aug 2013 - 00:01
    You still alive?
  2. Photo

    farrell2k Icon

    11 Jul 2013 - 18:05
    yo, brotha man!
  3. Photo

    shamsham Icon

    02 Jul 2013 - 01:21
    Thank you so much! :D
  4. Photo

    sasi9111 Icon

    22 Jun 2013 - 01:59
    hi flukeshot thaks for your advice . ill follow it.
Page 1 of 1