All pastes #444787 Raw Edit

plate

public text v1 · immutable
·published 2007-04-17 14:44 UTC
rendered paste body
/**
 * @(#)LicensePlate.java
 *
 * LicencePlate application
 *
 * @author Todd Le Blanc
 * @version 1.00 2007/4/13
 */
import java.util.*;

public class LicensePlate
{
    public static String licensePlate (String wordPlate)
    {
        String errorWords[] = {"LAME", "CRAP", "POOP"}; //
        //String legitWords[] = {"COOL", "NICE", "YEAH"};
        String replacePlate = "";
        long[] numberPlate = new long [3];

        for (int i = 0 ; i < 2 ; i++)
        {
            numberPlate [i] = 1 + (long)Math.random () * 10;
        }

        for (int i = 0 ; i < 2 ; i++)
        {

            if (wordPlate.equals (errorWords [i]))
            {
                wordPlate = legitWords [(long)Math.random () * 3];
            }
            else
            {
                replacePlate = wordPlate + " " + numberPlate [i]; //means the input doesnt have one of the "errorWords"
            }
        }

        return replacePlate; //returns a license plate that is appropriate
    }


    public static void main (String[] args)
    {
        String wordPlate = "LAME";
        String finalPlate;
        finalPlate = licensePlate (wordPlate); //takes whatever is returned as value => Calls the method "licensePlate"
        System.out.println ("An appropriate license plate is : " + finalPlate);
    }
}