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

Reputation: 2335 Grandmaster
Group:
Mentors
Active Posts:
4,891 (1.6 per day)
Joined:
11-December 07
Profile Views:
71,625
Last Active:
User is offline Yesterday, 04:42 PM
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: having trouble making my own exceptions

    Posted 28 Apr 2016

    Exceptions can be pretty simple if you want them to be:

    public class TooSmellyException extends Exception {
    }
    


    Then you can throw it with code such as:

    if (bo > 9000) {
      throw new TooSmellyException();
    }
    


    Any catching them is easy too:

    try {
      if (bo > 9000) {
        throw new TooSmellyException();
      }
    } catch (TooSmellyException e)  {
      System.out.println("Yuck!");
    }
    


    Exceptions like this are so quick and easy to code that there is no excuse not to use custom exceptions in your applications, and especially in your libraries.

    Sometimes you'll want to add a constructor that takes a string message, or one that takes the cause exception but they're not necessary all the time. If you're struggling, get used to the simple case first.
  2. In Topic: Setting minimum health for enemies in Text Based Game

    Posted 28 Apr 2016

    I was with you until near the end.

    			int min = 40;
    			int max = 100;
    			int health = rand.nextInt(max - min + 1) + min; 
    
  3. In Topic: What should I do next? feels like going nowhere...

    Posted 25 Apr 2016

    Another great problem site is
    http://rosalind.info...lems/locations/

    Maybe you need a project:
    http://www.dreaminco...-project-ideas/

    Maybe a different language would help you see the programming landscape differently:
    https://pragprog.com...-in-seven-weeks

    Or maybe you would like to learn about different kinds of program (e.g. console, desktop gui, smartphone app, browser plugin, web service, distributed, etc.)
  4. In Topic: Loop question

    Posted 24 Apr 2016

    Glad you could fix it. :)
  5. In Topic: Need help with loops.

    Posted 24 Apr 2016

    Draggonoth, your solution is very similar to mine:

    public class Calendar {
    	
    	public static void main(String[] args) {
    		printMonth("January", 31);
    		printMonth("February", 28);
    		printMonth("March", 31);
    		printMonth("April", 30);
    		printMonth("May", 31);
    		printMonth("June", 30);
    		printMonth("July", 31);
    		printMonth("August", 31);
    		printMonth("September", 30);
    		printMonth("October", 31);
    		printMonth("November", 30);
    		printMonth("December", 31);
    	}
    
    	private static void printMonth(String name, int days) {
    		System.out.print(name + ": 1");
    		for(int i = 2; i <= days; i++)
    			System.out.print(", " + i);
    		System.out.println(".");
    	}
    
    }
    
    

My Information

Member Title:
Cabbage
Age:
34 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://www.cfoley.co.uk
Twitter:
CFoleyUK

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