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

Reputation: 2155 Grandmaster
Group:
Mentors
Active Posts:
4,540 (1.67 per day)
Joined:
11-December 07
Profile Views:
65,003
Last Active:
User is offline Yesterday, 01:34 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: Why do people say they "don't like coding"...

    Posted 18 May 2015

    I think there is a deeper question here. I like to code. I like to work on my bike. I like to cook. I like to do martial arts. In fact I like to do almost anything where I can improve my skills over time. I've never understood people who do not.
  2. In Topic: Inheritance in my Ascii Animator Project

    Posted 14 May 2015

    Quote

    What are the buttons for? They're not in your assignment. Are they expected by your teacher?


    Quote

    I guess I don't necessarily need buttons, I could use an Input Handler and use the arrow keys as my method for moving back and forth and have key bindings such as CTRL+S to save and CTRL+L to load and CTRL+N to start a new frame, then extend JTextArea as my input field. Think that could work?


    Then I guess my next question is:

    What are the key bindings for? They're not in your assignment. Are they expected by your teacher?

    I was waiting for something to finish running earlier so I coded up my solution to your problem. Here is what are the public methods my animator class needed:

    public class AsciiAnimation extends JTextArea {
    
    	public AsciiAnimation(String[] frames) {
    	}
    
    	public void showNextFrame() {
    	}
    
    	public void showPreviousFrame() {
    	}
    
    	public void load(InputStream in) throws IOException, ClassNotFoundException {
    	}
    
    	public void save(OutputStream out) throws IOException {
    	}
    
    }
    
    


    The whole file was 42 lines long including imports and blank lines. There was one private method and two instance variables. There is nothing that's not asked for.

    I suppose you need some way of testing it. Here is what I did:

    import java.awt.event.*;
    import javax.swing.*;
    
    public class AnimationDemo {
    
    	public static void main(String[] args) {
    		String[] simpleAnimation = {
    			"\\ /\n X\n/ \\\n",
    			" \\ /\n  X\n / \\\n",
    			"  \\ /\n   X\n  / \\\n",
    			"   \\ /\n    X\n   / \\\n",
    			"    \\ /\n     X\n    / \\\n",
    			"     \\ /\n      X\n     / \\\n",
    			"    \\ /\n     X\n    / \\\n",
    			"   \\ /\n    X\n   / \\\n",
    			"  \\ /\n   X\n  / \\\n",
    			" \\ /\n  X\n / \\\n",
    		};
    		new AnimationDemo(simpleAnimation).launch();
    	}
    
    	private String[] frames;
    
    	public AnimationDemo(String[] frames) {
    		this.frames = frames;
    	}
    
    	public void launch() {
    		AsciiAnimation animation = new AsciiAnimation(frames);
    		putInFrame(animation).setVisible(true);
    		makeAnimationTimer(animation).start();
    	}
    
    	private JFrame putInFrame(JComponent c) {
    		JFrame frame = new JFrame();
    		frame.add(c);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setSize(200, 200);
    		return frame;
    	}
    
    	private Timer makeAnimationTimer(final AsciiAnimation animation) {
    		return new Timer(100, new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				animation.showNextFrame();
    			}
    		});
    	}
    	
    }
    


    Now, bear in mind that I'm not sitting your class and I did this for my own amusement. The appealing thing for me was watching the text move around so I used a timer to endlessly call showNextFrame(). I don't know what the teacher expects but you probably want your test program to call all the methods in the animation. If you want to do that with buttons then put them in your driver class. They're not part of the animation itself.
  3. In Topic: Inheritance in my Ascii Animator Project

    Posted 14 May 2015

    I think you're overthinking this one Infernorthor. The requirements which look like they are from the teacher are pretty simple.

    Quote

    So my project is to make an Ascii Animator, that has one custom class and this class should have the following capabilities:
    be an extension of JTextArea or something similar
    include the animation (probably as an array of Strings.)
    display text in a monospace font
    have methods for moving back and forth in the animation
    have methods for saving and loading the animation
    support animations of at least ten frames


    Now, I agree this is too much for one class but a simple implementation will have about 50 lines. You'll need one more class with a main method to start it all off.

    To the opening poster,

    Your assignment tells you to extend from JTextArea. Why are you extending JFrame?
    What are the buttons for? They're not in your assignment. Are they expected by your teacher?
    Think of your program as being in two parts:
    1. The class your teacher asked you to write.
    2. Another class to show off its capabilities.
  4. In Topic: converting a 2d int array into a string

    Posted 13 May 2015

    Use an if statement To choose between printing spaces snd printing the vslue.
  5. In Topic: IM's and SignalR

    Posted 13 May 2015

    It's just marketing. They're not new. Maybe a different twist on an existing idea but certainly not revolutionary. Whatsapp is just instant messaging but people use as a free SMS replacement on their phones. Yikyak is an anonymous Twitter from what I can gather. I challenge you to find any recent app that's not just a new take on a old idea.

My Information

Member Title:
Cabbage
Age:
33 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