Results 1 to 11 of 11
  1. #1
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from text

    Greetings,

    The problem I'm working on takes input such as

    s...pppp
    .xxx....p
    .xxx....p
    .xxx....f
    -

    where s = the starting position, f = final position, p = painted . = empty, x = blocked off, - end of input

    A cube must roll from the start to the finish, with all 6 sides covered in paint. There are specific rules which you can read here (Results, 2012 statements, 3rd problem), but I don't believe it's of very much importance to my problem.

    I have made a vertex object for each letter in the input. It has a state (empty, start position, finish position, blocked off, etc. ), above, below, left, and right variable. The above, below, left, and right point to one of the vertices beside it. The problem I'm having is actually taking the input and creating all the vertex objects, and setting the above, below, left, right variables. I have an attempt below, however it is only partially correct. I use one for loop to set up the lefts and right, and another to set up above and below. I can go vertex.getLeft().getLeft().getRight().getRight() all day and get the correct answers. I can go Vertex.getBelow() and get the correct answer, but I cannot go Vertex.getBelow().getLeft() or Right. This change in direction is where everything goes awry.

    I'm wondering:
    1 - If Java has support for a 2 dimensional "Multiply linked list" where each element in the list can have an above, below, left and right
    By two dimensional I don't necessarily mean a list of lists, unless that would easily work somehow
    2 - If there is a way better than mine to do this, or
    3 - How to fix mine and
    4 - How to fix my SSCCE

    Below is my attempted SSCCE:
    The two compiler errors I got were in the cube and vertex creation lines. Going from 4 separate java files to one caused this:

    "
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing instance of type Main (e.g. x.new A() where x is an instance of Main).
    "

    I'm somewhat new to Java, and my code is quite messy and incomplete, but the only part you should have to look at is the getInput() method.

    Thank-you for your time


    Java Code:
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.Queue;
    import java.util.Scanner;
    
    public class Main {
    
    	private static Vertex startingVertex;
    	private static Vertex firstVertex;
    	private Vertex endingVertex;
    	private static Cube parentCube;
    	private static Queue<Cube> openList; // Cubes remaining to be explored
    	private static Queue<Cube> closedList; // Explored cubes
    
    	public static void main(String[] args) {
    
    		getInput();
    		// make scanner, get input, turn input into a bunch of Vertex objects,
    		// and a cube
    
    		openList = new LinkedList<Cube>(); // Cubes remaining to be explored
    		closedList = new LinkedList<Cube>(); // Explored cubes
    
    		ArrayList<Vertex> currentChildren = new ArrayList<Vertex>();// current children at current level of depth
    
    		// start with starting vertex
    		// add starting vertex to openList
    		// generate children
    		// move starting vertex to closed list
    		// add children to openlist
    		// check if children solved
    
    		openList.add(parentCube);
    
    		while (!openList.isEmpty()) {
    			System.out.println(openList);
    			generateChildren(openList.remove());
    
    		}
    
    	}
    
    	private static void generateChildren(Cube current) {// TODO add left, right,
    														// below
    
    		if (current.getCurrentVertex().getAbove() != null) {
    
    			Cube aboveCube = new Cube(current);
    
    			aboveCube.rollUp(); // updates Cube's current Vertex, and move count
    
    			checkSolved(aboveCube);
    			checkIfRepeatState(aboveCube);
    			openList.add(aboveCube);
    		}
    
    	}
    
    	private static void getInput() {
    		Scanner s = new Scanner(System.in);
    
    		// create array of strings from input
    		ArrayList<String> list = new ArrayList<String>();
    		boolean endOfInput = false;
    		while (!endOfInput) {
    			String line = s.nextLine();
    			if (line.equals("-")) {
    				endOfInput = true;
    			} else {
    				list.add(line);
    			}
    		}
    
    		// create a two dimesional array of every inputed character
    		char[][] characterGrid = new char[list.size()][list.get(0).length()];
    
    		for (int j = 0; j < characterGrid.length; j++) {
    			for (int i = 0; i < characterGrid[j].length; i++) {
    				characterGrid[j][i] = list.get(j).charAt(i);
    			}
    		}
    
    		// sets up each Vertex's left and right variable
    		for (int j = 0; j < characterGrid.length; j++) {
    
    			Vertex previous = new Vertex(STATE.CLOSED);
    			for (int i = 0; i < characterGrid[j].length; i++) { // iterates through each horizontal line in the characterGrid
    
    				Vertex current = new Vertex(
    						characterToState(characterGrid[j][i]));
    				if (i == 0 && j == 0) {
    					firstVertex = current;
    				}
    				current.setLeft(previous);
    
    				previous.setRight(current);
    
    				previous = current;
    
    			}
    		}
    
    		// sets up each Vertex's above and below variable
    		for (int j = 0; j < characterGrid[0].length; j++) {
    			Vertex previous = new Vertex(STATE.CLOSED);
    			for (int i = 0; i < characterGrid.length; i++) {
    				Vertex current;
    				if (i == 0 && j == 0) {
    					current = firstVertex;
    				} else {
    					current = new Vertex(characterToState(characterGrid[i][j])); // TODOswitch variables so they are consistent
    				}
    				current.setAbove(previous);
    				previous.setBelow(current);
    
    				previous = current;
    
    			}
    		}
    
    	}
    
    	private static void checkSolved(Cube cube) { // TODO make it check if the
    													// cube is painted on all 6
    													// sides, and if cube is in
    													// finish position
    		if (cube.getBack() == STATE.PAINTED) {
    			System.out.print(cube.getMoveCount());
    			System.exit(0);
    		}
    	}
    
    	private static boolean checkIfRepeatState(Cube cube) {
    		// TODO if this cube equals some other cube on the closedList, delete
    		// this one
    		return false;
    	}
    
    	private static STATE characterToState(char a) {
    		switch (a) {
    		case '.':
    			return STATE.EMPTY;
    		case 'P':
    			return STATE.PAINTED;
    		case 'p':
    			return STATE.PAINTED;
    		case 'c':
    			return STATE.START;
    		case 'C':
    			return STATE.START;
    		case 'f':
    			return STATE.FINISH;
    		case 'F':
    			return STATE.FINISH;
    		case 'x':
    			return STATE.CLOSED;
    		case 'X':
    			return STATE.CLOSED;
    		}
    
    		System.out.println("bad input yo");
    		return STATE.CLOSED;
    
    	}
    
    	class Cube {
    		private STATE top;
    		private STATE bottom;
    		private STATE front;
    		private STATE back;
    		private STATE left;
    		private STATE right;
    		private Vertex currentVertex;
    		private int moveCount;
    
    		public Cube(Vertex start) {
    			this.currentVertex = start;
    
    			this.top = STATE.EMPTY;
    			this.back = STATE.EMPTY;
    			this.bottom = STATE.EMPTY;
    			this.front = STATE.EMPTY;
    			this.left = STATE.EMPTY;
    			this.right = STATE.EMPTY;
    			this.moveCount = 0;
    		}
    
    		public Cube(Cube parent) {
    
    			this.currentVertex = parent.getCurrentVertex();
    			this.top = parent.getTop();
    			this.back = parent.getBack();
    			this.bottom = parent.getBottom();
    			this.front = parent.getFront();
    			this.left = parent.getLeft();
    			this.right = parent.getRight();
    			this.moveCount = parent.getMoveCount();
    
    		}
    
    		public void rollUp() {
    			STATE temp = this.top;
    
    			this.top = this.front;
    			this.front = this.bottom;
    			this.bottom = this.back;
    			this.back = temp;
    
    			transferPaint(this.currentVertex, this.currentVertex.getAbove());
    			this.currentVertex = this.currentVertex.getAbove();
    		}
    
    		private void transferPaint(Vertex cube, Vertex ground) {
    
    			if (ground.getState() != STATE.START
    					&& ground.getState() != STATE.FINISH) {
    
    				STATE temp = cube.getState();
    
    				cube.setState(ground.getState());
    				ground.setState(temp);
    
    			}
    		}
    
    		public STATE getTop() {
    			return top;
    		}
    
    		public void setTop(STATE top) {
    			this.top = top;
    		}
    
    		public STATE getBottom() {
    			return bottom;
    		}
    
    		public void setBottom(STATE bottom) {
    			this.bottom = bottom;
    		}
    
    		public STATE getFront() {
    			return front;
    		}
    
    		public void setFront(STATE front) {
    			this.front = front;
    		}
    
    		public STATE getBack() {
    			return back;
    		}
    
    		public void setBack(STATE back) {
    			this.back = back;
    		}
    
    		public STATE getLeft() {
    			return left;
    		}
    
    		public void setLeft(STATE left) {
    			this.left = left;
    		}
    
    		public STATE getRight() {
    			return right;
    		}
    
    		public void setRight(STATE right) {
    			this.right = right;
    		}
    
    		public Vertex getCurrentVertex() {
    			return currentVertex;
    		}
    
    		public void setCurrentVertex(Vertex currentVertex) {
    			this.currentVertex = currentVertex;
    		}
    
    		public int getMoveCount() {
    			return moveCount;
    		}
    
    		public void setMoveCount(int moveCount) {
    			this.moveCount = moveCount;
    		}
    
    	}
    
    	class Vertex {
    		private Vertex above;
    		private Vertex below;
    		private Vertex left;
    		private Vertex right;
    		private STATE state;
    
    		public Vertex(STATE theState) {
    			this.state = theState;
    			this.above = null;
    			this.below = null;
    			this.left = null;
    			this.right = null;
    		}
    
    		public Vertex(Vertex clone) {
    			this.state = clone.getState();
    			this.above = clone.getAbove();
    			this.below = clone.getBelow();
    			this.left = clone.getLeft();
    			this.right = clone.getRight();
    		}
    
    		public Vertex getAbove() {
    			return above;
    		}
    
    		public void setAbove(Vertex above) {
    			this.above = above;
    		}
    
    		public Vertex getBelow() {
    			return below;
    		}
    
    		public void setBelow(Vertex below) {
    			this.below = below;
    		}
    
    		public Vertex getLeft() {
    			return left;
    		}
    
    		public void setLeft(Vertex left) {
    			this.left = left;
    		}
    
    		public Vertex getRight() {
    			return right;
    		}
    
    		public void setRight(Vertex right) {
    			this.right = right;
    		}
    
    		public STATE getState() {
    			return state;
    		}
    
    		public void setState(STATE state) {
    			this.state = state;
    		}
    
    		@Override
    		public String toString() {
    			return "Vertex [state=" + state + "]";
    		}
    
    	}
    
    	public enum STATE {
    		START, FINISH, EMPTY, PAINTED, CLOSED
    	}
    }
    Last edited by Germoose; 01-04-2013 at 06:46 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,395
    Rep Power
    25

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Can you copy and post here the full text of the compiler errors that shows the source lines where the errors happen?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Quote Originally Posted by Norm View Post
    Can you copy and post here the full text of the compiler errors that shows the source lines where the errors happen?
    Oh sorry, the same two errors are on line 48 and 86.

    "
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing instance of type Main (e.g. x.new A() where x is an instance of Main).

    at Main.getInput(Main.java:87)
    at Main.main(Main.java:17)
    "

    Which corresponds to
    line 48 : " Cube aboveCube = new Cube(current);"
    line 87 : "Vertex previous = new Vertex(STATE.CLOSED);"

    Thank you for your time
    Last edited by Germoose; 01-04-2013 at 06:48 AM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,395
    Rep Power
    25

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    No enclosing instance of type Main is accessible.
    Sorry, I'm not familiar with that error message. Can you use the javac command to compile the code instead of your IDE?
    It will print error messages in this format: Here is a sample:
    Java Code:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    (e.g. x.new A() where x is an instance of Main).
    Have you tried what the error message suggests?

    The error could be because you are using static methods instead of instance methods. Try changing all the methods to instance methods.
    Last edited by Norm; 01-04-2013 at 04:10 PM. Reason: Fixed spelling
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Quote Originally Posted by Norm View Post
    Sorry, I'm not familiar with that error message. Can you use the javac command to compile the code instead of your IDE?
    It will print error messages in this format: Here is a sample:
    Java Code:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    When I tried javac-ing them in command prompt and got this error:

    Java Code:
    C:\......\src>javac Main.java
    Main.java:54: error: non-static variable this cannot be referenced from a static
     context
                            Cube aboveCube = new Cube(current);
                                             ^
    Main.java:97: error: non-static variable this cannot be referenced from a static
     context
                            Vertex previous = new Vertex(STATE.CLOSED);
                                              ^
    Main.java:104: error: non-static variable this cannot be referenced from a stati
    c context
                                    Vertex current = new Vertex(
                                                     ^
    Main.java:120: error: non-static variable this cannot be referenced from a stati
    c context
                            Vertex previous = new Vertex(STATE.CLOSED);
                                              ^
    Main.java:126: error: non-static variable this cannot be referenced from a stati
    c context
                                            current = new Vertex(characterToState(ch
    aracterGrid[i][j])); // TODOswitch
                                                      ^
    5 errors
    
    C:\.......\src>
    I'm not really sure what this means. Does this mean I can't create non-static objects such as Vertex and Cube from Main and it's methods, which is static? And why could I do this before, when they were separate files?

    Quote Originally Posted by Norm View Post
    Have you tried what the error message suggests?

    The error could be because you are using static methods instead of instance methods. Try changing all the methods to instance methods.
    If I turn the methods within Main to non-static methods, I get this error, from trying to use non static methods within the static Main class.

    Java Code:
    C:\.....\src>javac Main.java
    Main.java:18: error: non-static method getInput() cannot be referenced from a st
    atic context
                    getInput();
                    ^
    Main.java:43: error: non-static method generateChildren(Main.Cube) cannot be ref
    erenced from a static context
                            generateChildren(openList.remove());
                            ^
    2 errors
    
    C:\.....\src>
    Maybe I'm confused on some fundamentals with static/non-static.

    Thanks for your time.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,395
    Rep Power
    25

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    If I turn the methods within Main to non-static methods
    Change the main() method so it only calls the class's constructor and put all the code in the main() method in the constructor.
    The constructor being in an instance of the class will be able to access all the inner classes.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Quote Originally Posted by Norm View Post
    Change the main() method so it only calls the class's constructor and put all the code in the main() method in the constructor.
    The constructor being in an instance of the class will be able to access all the inner classes.
    I'm not exactly sure what you mean.

    Turn this :
    Java Code:
    public static void main(String[] args) {
    		
    		
    		getInput();
    		// make scanner, get input, turn input into a bunch of Vertex objects,
    		// and a cube
    
    		openList = new LinkedList<Cube>(); // Cubes remaining to be explored
    		closedList = new LinkedList<Cube>(); // Explored cubes
    
    		ArrayList<Vertex> currentChildren = new ArrayList<Vertex>();// current
    																	// children
    																	// at
    																	// current
    																	// level of
    																	// depth
    
    		// start with starting vertex
    		// add starting vertex to openList
    		// generate children
    		// move starting vertex to closed list
    		// add children to openlist
    		// check if children solved
    
    		openList.add(parentCube);
    
    		while (!openList.isEmpty()) {
    			System.out.println(openList);
    			generateChildren(openList.remove());
    
    		}
    
    	}
    Into this:
    Java Code:
    public Main(){
    		getInput();
    		// make scanner, get input, turn input into a bunch of Vertex objects,
    		// and a cube
    
    		openList = new LinkedList<Cube>(); // Cubes remaining to be explored
    		closedList = new LinkedList<Cube>(); // Explored cubes
    
    		ArrayList<Vertex> currentChildren = new ArrayList<Vertex>();// current
    																	// children
    																	// at
    																	// current
    																	// level of
    																	// depth
    
    		// start with starting vertex
    		// add starting vertex to openList
    		// generate children
    		// move starting vertex to closed list
    		// add children to openlist
    		// check if children solved
    
    		openList.add(parentCube);
    
    		while (!openList.isEmpty()) {
    			System.out.println(openList);
    			generateChildren(openList.remove());
    
    		}
    	}
    	public static void main(String[] args) {
    		
    		Main m = new Main(); 
    		
    
    	}
    When I do that I get the same errors :

    Java Code:
    C:\...\src>javac Main.java
    Main.java:57: error: non-static variable this cannot be referenced from a static
     context
                            Cube aboveCube = new Cube(current);
                                             ^
    Main.java:100: error: non-static variable this cannot be referenced from a stati
    c context
                            Vertex previous = new Vertex(STATE.CLOSED);
                                              ^
    Main.java:107: error: non-static variable this cannot be referenced from a stati
    c context
                                    Vertex current = new Vertex(
                                                     ^
    Main.java:123: error: non-static variable this cannot be referenced from a stati
    c context
                            Vertex previous = new Vertex(STATE.CLOSED);
                                              ^
    Main.java:129: error: non-static variable this cannot be referenced from a stati
    c context
                                            current = new Vertex(characterToState(ch
    aracterGrid[i][j])); // TODOswitch
                                                      ^
    5 errors
    
    C:\....\src>

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,395
    Rep Power
    25

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    If I turn the methods within Main to non-static methods,
    Did you have all the methods non-static? All methods should be instance methods not static.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Quote Originally Posted by Norm View Post
    Did you have all the methods non-static? All methods should be instance methods not static.
    Wow, it seems you are right. I missed a method. Now every method inside main has been changed to non-static as such:

    Java Code:
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.Queue;
    import java.util.Scanner;
    
    public class Main {
    
    	private static Vertex startingVertex;
    	private static Vertex firstVertex;
    	private Vertex endingVertex;
    	private static Cube parentCube;
    	private static Queue<Cube> openList; // Cubes remaining to be explored
    	private static Queue<Cube> closedList; // Explored cubes
    	
    	public Main(){
    		getInput();
    		// make scanner, get input, turn input into a bunch of Vertex objects,
    		// and a cube
    
    		openList = new LinkedList<Cube>(); // Cubes remaining to be explored
    		closedList = new LinkedList<Cube>(); // Explored cubes
    
    		ArrayList<Vertex> currentChildren = new ArrayList<Vertex>();// current
    																	// children
    																	// at
    																	// current
    																	// level of
    																	// depth
    
    		// start with starting vertex
    		// add starting vertex to openList
    		// generate children
    		// move starting vertex to closed list
    		// add children to openlist
    		// check if children solved
    
    		openList.add(parentCube);
    
    		while (!openList.isEmpty()) {
    			System.out.println(openList);
    			generateChildren(openList.remove());
    
    		}
    	}
    	public static void main(String[] args) {
    		
    		Main m = new Main(); 
    		
    
    	}
    
    	private void generateChildren(Cube current) {// TODO add left, right,
    														// below
    
    		if (current.getCurrentVertex().getAbove() != null) {
    
    			Cube aboveCube = new Cube(current);
    
    			aboveCube.rollUp(); // updates Cube's current Vertex, and move count
    
    			checkSolved(aboveCube);
    			checkIfRepeatState(aboveCube);
    			openList.add(aboveCube);
    		}
    
    	}
    
    	private void getInput() {
    		Scanner s = new Scanner(System.in);
    
    		// create array of strings for input
    		ArrayList<String> list = new ArrayList<String>();
    		boolean endOfInput = false;
    		while (!endOfInput) {
    			String line = s.nextLine();
    			if (line.equals("-")) {
    				endOfInput = true;
    			} else {
    				list.add(line);
    			}
    		}
    
    		// create a two dimesional array of every inputed character
    		char[][] characterGrid = new char[list.size()][list.get(0).length()];
    		System.out.println("list string size: " + list.get(0).length()
    				+ " list array size: " + list.size());
    		System.out.println("characterGrid length: " + characterGrid.length
    				+ " characterGridARrayLength: " + characterGrid[0].length);
    
    		for (int j = 0; j < characterGrid.length; j++) {
    			for (int i = 0; i < characterGrid[j].length; i++) {
    				System.out.println(j + " " + i);
    				characterGrid[j][i] = list.get(j).charAt(i);
    			}
    		}
    
    		// sets up each Vertex's left and right variable
    		for (int j = 0; j < characterGrid.length; j++) {
    
    			Vertex previous = new Vertex(STATE.CLOSED);
    			for (int i = 0; i < characterGrid[j].length; i++) { // iterates
    																// through each
    																// horizontal
    																// line in the
    																// characterGrid
    
    				Vertex current = new Vertex(
    						characterToState(characterGrid[j][i]));
    				if (i == 0 && j == 0) {
    					firstVertex = current;
    				}
    				current.setLeft(previous);
    
    				previous.setRight(current);
    
    				previous = current;
    
    			}
    		}
    
    		// sets up each Vertex's above and below variable
    		for (int j = 0; j < characterGrid[0].length; j++) {
    			Vertex previous = new Vertex(STATE.CLOSED);
    			for (int i = 0; i < characterGrid.length; i++) {
    				Vertex current;
    				if (i == 0 && j == 0) {
    					current = firstVertex;
    				} else {
    					current = new Vertex(characterToState(characterGrid[i][j])); // TODOswitch
    																					// variables
    																					// so
    																					// they
    																					// are
    																					// consistent
    				}
    				current.setAbove(previous);
    				previous.setBelow(current);
    
    				previous = current;
    
    			}
    		}
    
    	}
    
    	private void checkSolved(Cube cube) { // TODO make it check if the
    													// cube is painted on all 6
    													// sides, and if cube is in
    													// finish position
    		if (cube.getBack() == STATE.PAINTED) {
    			System.out.print(cube.getMoveCount());
    			System.exit(0);
    		}
    	}
    
    	private boolean checkIfRepeatState(Cube cube) {
    		// TODO if this cube equals some other cube on the closedList, delete
    		// this one
    		return false;
    	}
    
    	private STATE characterToState(char a) {
    		switch (a) {
    		case '.':
    			return STATE.EMPTY;
    		case 'P':
    			return STATE.PAINTED;
    		case 'p':
    			return STATE.PAINTED;
    		case 'c':
    			return STATE.START;
    		case 'C':
    			return STATE.START;
    		case 'f':
    			return STATE.FINISH;
    		case 'F':
    			return STATE.FINISH;
    		case 'x':
    			return STATE.CLOSED;
    		case 'X':
    			return STATE.CLOSED;
    		}
    
    		System.out.println("bad input yo");
    		return STATE.CLOSED;
    
    	}
    This compiles with zero errors! Thank you. However, I don't understand why that was necessary for a single file but it isn't for multiple files.

    Thank you for your time.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,395
    Rep Power
    25

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    The inner classes were the problem. If they were outside the Main class there shouldn't be a problem. They could still be in the same file.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    Germoose is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Creating vertices with getLeft(), getRight(), getAbove(), and getBelow() from tex

    Quote Originally Posted by Norm View Post
    The inner classes were the problem. If they were outside the Main class there shouldn't be a problem. They could still be in the same file.
    Ooo Ok thanks a lot. That solves my sscce troubles.

Similar Threads

  1. Creating Ouput Text File
    By Raian in forum New To Java
    Replies: 14
    Last Post: 05-24-2010, 09:56 AM
  2. creating a graph from a text file
    By chinolee in forum New To Java
    Replies: 3
    Last Post: 11-23-2009, 08:36 AM
  3. Creating&Saving as a different Text file
    By right2001 in forum New To Java
    Replies: 2
    Last Post: 04-07-2009, 07:17 AM
  4. creating a text based game
    By Phobos0001 in forum New To Java
    Replies: 1
    Last Post: 02-12-2008, 04:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •