<commit_before>/**
 * @file OthelloPieceColourChanger.java
 *
 * @author <NAME>
 *
 * @date 25 Feb '14
 *
 * @brief Animates the Othello board pieces.
 *
 * This classes, when passed a piece
 */

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class OthelloPieceColourChanger extends JFrame {

	private JLabel container;
	private ImageIcon blackToWhite;
	private ImageIcon whiteToBlack;
    private static OthelloPieceColourChanger m_ColourChanger;
    private static ImageIcon m_ImageIcon;

	public OthelloPieceColourChanger(){}

	/**
	 *	Calls either blackToWhiteFlip() method or whiteToBlackFlip() method depending on the
	 *	input from the getColour() method parsed in from the Piece class.
	 *	@param p			Parses in the Piece class so that method can get colour of piece.
	 *	@return	ImageIcon	This returns the gif image which represents
	 *  the piece flipping when a colour is changed in the Othello game.
	 */
	public ImageIcon flip(Piece p){
		if (p.getColour().equals("Black")){
			return whiteToBlackFlip();
		}
		else if (p.getColour().equals("White")){
			return blackToWhiteFlip();
		}
		else {
			return new ImageIcon();
		}
	}

	/**
	 *	Fetches the gif which animates the piece flipping from black to white and returns it.
	 *	@return	blackToWhite	The animated Gif which flips a piece from black to white.
	 */
	private ImageIcon blackToWhiteFlip(){
		ImageIcon blackToWhite = new ImageIcon("../Images/BlackToWhitePiece.gif");
		blackToWhite.getImage().flush();
		return blackToWhite;
	}

	/**
	 *	Fetches the gif which animates the piece flipping from white to black and returns it.
	 *	@return	whiteToBlack	The animated Gif which flips a piece from white to black.
	 */
	private ImageIcon whiteToBlackFlip(){
		ImageIcon whiteToBlack = new ImageIcon("../Images/WhiteToBlackPiece.gif");
		whiteToBlack.getImage().flush();
		return whiteToBlack;
	}

	public static void main(String[] args) throws IOException {

        //	Tests whether the black to white gif animation from file equals the gif animation parsed
        //	out from the ColourChange class.

            m_ColourChanger = new OthelloPieceColourChanger();
            m_ImageIcon = new ImageIcon("Images/BlackToWhitePiece.gif");


        if(m_ColourChanger.flip(new Piece("White")).getImage().equals(m_ImageIcon.getImage())) {
            System.out.println("OthelloPieceColourChanger Test One BlackToWhite Evaluated: Correct");
        } else {
            System.out.println("OthelloPieceColourChanger Test One BlackToWhite Evaluated: Incorrect");
        }


        //	Tests whether the white to black gif animation from file equals the gif animation parsed
        //	out from the ColourChange class.

            m_ColourChanger = new OthelloPieceColourChanger();
            m_ImageIcon = new ImageIcon("Images/WhiteToBlackPiece.gif");


        if(m_ColourChanger.flip(new Piece("Black")).getImage().equals (m_ImageIcon.getImage())) {
            System.out.println("OthelloPieceColourChanger Test Two WhiteToBlack Evaluated: Correct");
        } else {
            System.out.println("OthelloPieceColourChanger Test Two WhiteToBlack Evaluated: Incorrect");
        }


        //	Tests if an incorrect string is inputted so that it doesn't output one of the GIFs and outputs
        //	a blank ImageIcon.

            m_ColourChanger = new OthelloPieceColourChanger();
            m_ImageIcon = new ImageIcon();

        try {
         if(m_ColourChanger.flip(new Piece("Blue")).getImage().equals (m_ImageIcon.getImage())) {
            System.out.println("OthelloPieceColourChanger Test Three BlankIcon Evaluated: Correct");
        }

        } catch (Exception e) {

            System.out.println("OthelloPieceColourChanger Test Three BlankIcon Evaluated: Invalid String Entered");

        }

	}
}<commit_msg>Fixed Tests on OthelloPieceColourChanger<commit_after>/**
 * @file OthelloPieceColourChanger.java
 *
 * @author <NAME>
 *
 * @date 25 Feb '14
 *
 * @brief Animates the Othello board pieces.
 *
 * @detail When passed a piece object, this class returns the appropriate flipping ImageIcon
 */

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class OthelloPieceColourChanger extends JFrame {

	private JLabel container;
	private ImageIcon blackToWhite;
	private ImageIcon whiteToBlack;
    private static OthelloPieceColourChanger m_ColourChanger;
    private static ImageIcon m_ImageIcon;

	public OthelloPieceColourChanger(){}

	/**
	 *	Calls either blackToWhiteFlip() method or whiteToBlackFlip() method depending on the
	 *	input from the getColour() method parsed in from the Piece class.
	 *	@param p			Parses in the Piece class so that method can get colour of piece.
	 *	@return	ImageIcon	This returns the gif image which represents
	 *  the piece flipping when a colour is changed in the Othello game.
	 */
	public ImageIcon flip(Piece p){
		if (p.getColour().equals("Black")){
			return whiteToBlackFlip();
		}
		else if (p.getColour().equals("White")){
			return blackToWhiteFlip();
		}
		else {
			return new ImageIcon();
		}
	}

	/**
	 *	Fetches the gif which animates the piece flipping from black to white and returns it.
	 *	@return	blackToWhite	The animated Gif which flips a piece from black to white.
	 */
	private ImageIcon blackToWhiteFlip(){
		ImageIcon blackToWhite = new ImageIcon("../Images/BlackToWhitePiece.gif");
		blackToWhite.getImage().flush();
		return blackToWhite;
	}

	/**
	 *	Fetches the gif which animates the piece flipping from white to black and returns it.
	 *	@return	whiteToBlack	The animated Gif which flips a piece from white to black.
	 */
	private ImageIcon whiteToBlackFlip(){
		ImageIcon whiteToBlack = new ImageIcon("../Images/WhiteToBlackPiece.gif");
		whiteToBlack.getImage().flush();
		return whiteToBlack;
	}

	/**
	 * Main method for class tests on OthelloPieceColourChanger
	 */
	public static void main(String[] args) throws IOException {

		final String blackToWhiteGif = "../Images/BlackToWhitePiece.gif";
		final String whiteToBlackGif = "../Images/WhiteToBlackPiece.gif";
		
        //	Tests whether the black to white gif animation from file equals the gif animation parsed
        //	out from the ColourChange class.

		OthelloPieceColourChanger testColourChanger1 = new OthelloPieceColourChanger();
         ImageIcon testImage1 = testColourChanger1.flip(new Piece("White"));
         System.out.println(testImage1.toString());

        if(testImage1.toString().equals(blackToWhiteGif)) {
            System.out.println("OthelloPieceColourChanger Test One Evaluated: Correct");
        } else {
            System.out.println("OthelloPieceColourChanger Test One Evaluated: Incorrect");
        }


        //	Tests whether the white to black gif animation from file equals the gif animation parsed
        //	out from the ColourChange class.

        
        
        OthelloPieceColourChanger testColourChanger2 = new OthelloPieceColourChanger();
        ImageIcon testImage2 = testColourChanger2.flip(new Piece("Black"));   

        if(testImage2.toString().equals(whiteToBlackGif)) {
            System.out.println("OthelloPieceColourChanger Test Two Evaluated: Correct");
        } else {
            System.out.println("OthelloPieceColourChanger Test Two Evaluated: Incorrect");
        }


        //	Tests if an incorrect string is inputted so that it doesn't output one of the GIFs and outputs
        //	a blank ImageIcon.

        OthelloPieceColourChanger testColourChanger3 = new OthelloPieceColourChanger();
        ImageIcon testImage3 = testColourChanger3.flip(new Piece("Blue")); 
        
        try {
         if(testImage3.toString().equals(blackToWhiteGif) || testImage3.toString().equals(whiteToBlackGif)) {
            System.out.println("OthelloPieceColourChanger Test Three Evaluated: Incorrect");
        } else {
        	System.out.println("OthelloPieceColourChanger Test Three Evaluated: Correct");
        }

        } catch (Exception e) {

            System.out.println("OthelloPieceColourChanger Test Three Could not accept incorrect Piece input (intended)");
            System.out.println("OthelloPieceColourChanger Test Three BlankIcon Evaluated: Correct");

        }

	}
}
{'fraction_non_alphanumeric': 0.09158945117605131, 'fraction_numerical': 0.002613447374673319, 'mean_word_length': 3.3917579551382366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4534881', 'n_tokens_mistral': 2639, 'n_tokens_neox': 2462, 'n_words': 731}