package lab.games; import javax.swing.JFrame; import javax.swing.JTextArea; /** * An ASCIImation has a sequence of frames. * * @author */ public class ASCIImation { /** * Initializes this ASCIImation from the file with the given name. * The file contains one of more frames, each followed by an empty line. * Each frame consists of 5 lines of ASCII characters and each line * contains at most 80 characters. * * @param fileName the name of the file with the content of this ASCIImation. * @pre. the file is in the right format. * @throws FileNotFoundException if the file with the given name cannot be found. */ public ASCIImation(String fileName) throws FileNotFoundException { } /** * Returns the number of frames of this ASCIImation. * * @return the number of frames of this ASCIImation. */ public int getNumberOfFrames() { } /** * Returns the frame of this ASCIImation with the given index. * * @param index the index of the frame. * @pre. index >= 0 && index < number of frames * @return the frame of this ASCIImation with the given index. */ public Frame getFrame(int index) { } /** * Reverses the order of the frames of this ASCIImation. */ public void reverse() { } /** * Repeats the frames of this ASCIImation indefinitely. * * @throws UnsupportedOperationException if this optional method is not implemented. */ public void repeat() throws UnsupportedOperationException { } /** * Plays this ASCIImation. */ public void play() { final int WIDTH = 1000; final int HEIGTH = 120; JFrame frame = new JFrame("ASCIImation"); frame.setSize(WIDTH, HEIGTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea area = new JTextArea(Frame.HEIGHT, Frame.WIDTH); frame.add(area); frame.setVisible(true); final int DELAY = 500; try { for (int i = 0; i < this.getNumberOfFrames(); i++) { area.setText(this.getFrame(i).toString()); Thread.sleep(DELAY); } } catch (InterruptedException e) {} } }