cfoley's Profile User Rating: -----

Reputation: 2045 Grandmaster
Group:
Mentors
Active Posts:
4,232 (1.69 per day)
Joined:
11-December 07
Profile Views:
59,262
Last Active:
User is offline Today, 06:36 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
225
Expert In:
Java

Latest Visitors

Icon   cfoley has not set their status

Posts I've Made

  1. In Topic: List vs Set Assignment

    Posted 23 Oct 2014

    Yes and yes, but by now you could have tried it. The computer will tell you far more reliably than a person. Always try the next step yourself and come back if you get stuck.
  2. In Topic: what is the errors that I am missing here and not seeing

    Posted 23 Oct 2014

    sum = (3kg5oog + 4kg700g)


    Java knows nothing of grams and kilograms, only numbers. Grams and Kilograms would have to go into different variables:

    int myKilograms = 3;
    int myGrams = 500; // Note: 500 not 5oo!
    
    int yourKiligrams = 4;
    int yourGrams = 700;
    


    That's kind of nasty and makes calculations difficult. Let's combine the kilograms and grams to make calculations easier.

    int myTotalGrams = (1000 * myKilograms) + myGrams;
    int yourTotalGrams = (1000 * yourKilograms) + yourGrams;
    


    Now we can add them together:

    int everyonesTotalGrams = myTotalGrams + yourTotalGrams;
    


    And split them apart

    int everyonesKilograms = everyonesTotalGrams / 1000; // this will round down
    int everyonesGrams = everyonesTotalGrams % 1000; // This is the remainder from dividing
    


    and print them out

    System.out.println("We have " + everyonesKilograms + " kg and " + everyonesGrams + " g between us.");
    
  3. In Topic: Subclass or String issues?

    Posted 22 Oct 2014

    Lines in a file or from System.in end in an invisible newline character. nextInt() only reads the digits, leaving the newLine. The next call to nextLine() will read to the end of the current line which in this case is just the newline character (remember, the digits have already been read). To make matters worse, the newline character is removed from the return value so all you get is an empty string.
  4. In Topic: Full-screen works 50% of the time Ubuntu

    Posted 22 Oct 2014

    I just tried it on my Windows laptop. It would always go to fullscreen but never leave it. I tweaked your key listener and it works on my system. How does this work on yours?

    package fullScreen;
    
    import java.awt.*;
    import java.awt.event.*;
    
    import javax.swing.*;
    
    public class KeyManager implements KeyListener
    {
    
    	public GraphicsDevice gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    	public boolean full = false;
    	
    	public void keyPressed(KeyEvent e) {
    		if (e.getKeyCode() == KeyEvent.VK_SPACE)
    			Main.stop();
    		if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
    			toggleFullScreen();
    	}
    
    	private void toggleFullScreen() {
    		JFrame next = full ? null : Main.frame;
    		gs.setFullScreenWindow(next);
    		full = !full;
    	}
    
    	@Override public void keyReleased(KeyEvent arg0){}
    	@Override public void keyTyped(KeyEvent arg0){}
    }
    
    
    
    
  5. In Topic: Linked List Queue toString method problems

    Posted 22 Oct 2014

    View PostOptimusOmega, on 22 October 2014 - 06:43 PM, said:

    I appreciate the help, but I just felt like there was an easier way to do it, and in searching the net I found that this works perfectly
    public String toString()
       {
          String result = "";
          LLNode<T> current = front;
    
          while (current != null)
          {
             result = result + (current.getInfo()).toString() + "\n";
             current = current.getLink();
          }
          return result;
       }
    
    

    Tested and works. But again, thank you guys.


    Yeah that looks fine but it's not recursive, which is what you asked for.

My Information

Member Title:
Cabbage
Age:
32 years old
Birthday:
April 7, 1982
Gender:
Location:
Glasgow
Forum Leader:
Java
Years Programming:
20

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://

Comments

Page 1 of 1
  1. Photo

    burakaltr Icon

    06 Mar 2013 - 18:18
    Thanks for Your Precious Input. I Found the character counting thing very bedazzling. I have the code to it that I wrote Myself, but it took me Long to find a subtle Algorithm :)
  2. Photo

    cfoley Icon

    18 Oct 2011 - 03:29
    Cheers! The next one is in progress, but I'm having to learn and write some programs first. It's going to take a little time...
  3. Photo

    Dogstopper Icon

    18 Oct 2011 - 03:24
    Nice blog. Can't wait to see more
  4. Photo

    ayaz 786123 Icon

    25 Feb 2011 - 06:49
    have a nice day sir
  5. Photo

    cfoley Icon

    16 Feb 2011 - 17:26
    Oooh thanks! Your comment is the first I heard!
  6. Photo

    m-e-g-a-z Icon

    16 Feb 2011 - 15:34
    Congrats on becoming a Forum Leader! :)
  7. Photo

    Dogstopper Icon

    08 Jan 2011 - 23:49
    "Cabbage" is much better! :D
  8. Photo

    cfoley Icon

    06 Jan 2011 - 16:19
    Cheers dude!
  9. Photo

    Dogstopper Icon

    06 Jan 2011 - 14:36
    "Purple DIC-headed Warrior" doesn't quite apply now that you got the promotion. Well done!
  10. Photo

    DaneAU Icon

    08 Sep 2010 - 09:19
    "cfoley has no profile comments yet. Why not say hello?"
    I don't have many comments either, so i am only doing what the thingy below said to do, hello cfoley and thanks for the thanks :)
Page 1 of 1