okay so ive finished this code but now i have to modify it so that it uses the following lines of code to make the program "easier" to understand
private static void writeText(BillboardInterface billboard, int x, int y, String text)
private static void writeLetter(BillboardInterface billboard, int x, int y, char c)
private static void write_s(BillboardInterface billboard, int x, int y)
private static void write_p(BillboardInterface billboard, int x, int y)
private static void write_a(BillboardInterface billboard, int x, int y)
private static void write_r(BillboardInterface billboard, int x, int y)
private static void write_e(BillboardInterface billboard, int x, int y)
ive implemented the lines into my program and it compiles however when i try inserting code or each write_# i get a error saying Cannot find symbol - variable START_X.
here is the code so far
import java.util.Scanner;
import billboard.BillboardInterface;
import billboard.DigitalBillboardFrame;
import javax.swing.JOptionPane;
/**
* Partial solution for Stage 2 of the digital billboard
*
* @author phi
* @version 2011 2
*/
public class testClass
{
public static void main(String[] args)
{
// initial size of the display in pixels
final int WINDOW_WIDTH = 300;
final int WINDOW_HEIGHT = 120;
// size of the grid for the digital billboard
final int BB_WIDTH = 50;
final int BB_HEIGHT = 30;
// create a billboard
BillboardInterface billboard = new DigitalBillboardFrame(
"SCSS",
WINDOW_WIDTH, WINDOW_HEIGHT,
BB_WIDTH, BB_HEIGHT);
// we will make letters 5 cells wide and 12 high
final int LETTER_WIDTH = 5;
final int LETTER_HEIGHT = 12;
// and leave a 1 cell gap between letters
final int GAP = 1;
// the top left of the first letter in the word will be 2 cells from the left and 1 down
final int START_X = 10;
final int START_Y = 8;
final boolean isJOptionPaneUsed = true; //for Scanner (0) or JOptionPane (1);
String inputString; // input string recved
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// first make sure the display is blank
billboard.allOff();
// forever
for(;;)
{
if (isJOptionPaneUsed)
{
//get a message from the user
// Get user input
inputString = JOptionPane.showInputDialog("Enter a 5 letter word made up of the letters ‘s’, ‘p’, ‘a’, ‘r’ and ‘e’ ");
}
else
{
keyboard = new Scanner(System.in);
System.out.println("\nEnter a 5 letter word made up of the letters ‘s’, ‘p’, ‘a’, ‘r’ and ‘e’ ");
String input = keyboard.nextLine();
}
// first make sure the display is blank
billboard.allOff();
//for each letter in the message
int x = START_X; // keep track of where each letter should go
int y = START_Y;
for(int i = 0; i < 5; i++)
{
// display the i_th letter
switch((inputString).charAt(i))
{
case 's':
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+8);
break;
case 'p':
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP),START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+9);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+10);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+11);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+12);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+8);
break;
case 'a':
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+8);
break;
case 'r':
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP),START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+3);
break;
case'e':
write_e(billboard, x, y);
break;
break;
default:
}
x += LETTER_WIDTH + GAP;
// display the letter
}
// OK - ready to update the display
billboard.redisplay(0);
}
}
private static void writeText(BillboardInterface billboard, int x, int y, String text)
{
}
private static void writeLetter(BillboardInterface billboard, int x, int y, char c)
{
}
private static void write_s(BillboardInterface billboard, int x, int y)
{
}
private static void write_p(BillboardInterface billboard, int x, int y)
{
}
private static void write_a(BillboardInterface billboard, int x, int y)
{
}
private static void write_r(BillboardInterface billboard, int x, int y)
{
}
private static void write_e(BillboardInterface billboard , int x, int y)
{
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+2);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+6);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP), START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+5);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+4);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+3);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+4, START_Y+7);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+3, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+2, START_Y+8);
billboard.turnOn(START_X+i*(LETTER_WIDTH+GAP)+1, START_Y+8);
}
}
im figuring there maybe something wrong with line 195 but cant seem to get it.
thank you