CountBale's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
28 (0.04 per day)
Joined:
22-January 13
Profile Views:
404
Last Active:
User is offline Dec 01 2014 05:43 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   CountBale has not set their status

Posts I've Made

  1. In Topic: Eigen Vector Calculations for OBB crashing on second pass through “Ass

    Posted 28 Nov 2014

    Yeah, ill try that tomorrow, I finally headed home after 8 hours of beating my head against the wall with this problem.
  2. In Topic: Eigen Vector Calculations for OBB crashing on second pass through “Ass

    Posted 28 Nov 2014

    Ah, sorry. I realize I worded that confusingly. The first line of the above section is the line that causes the crash, the line where "computd_EigenV" is called. The specific part of that function that causes the crash is the section where all_eigenvalues is called. Sorry for the confusion.
  3. In Topic: Eigen Vector Calculations for OBB crashing on second pass through “Ass

    Posted 28 Nov 2014

    Yeah, that's the idea.
  4. In Topic: Eigen Vector Calculations for OBB crashing on second pass through “Ass

    Posted 28 Nov 2014

    Just tried that, Visual Studio doesn't seem to like me chaining the operators in that way, it gives Error: no operator "<<" matches these operands.
  5. In Topic: Popping the top value of a stack and adding it to a queue

    Posted 12 Dec 2013

    The whole class is here:

    package lab9;
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.Queue;
    import java.util.Stack;
    
    public class StringCalculator 
    {
    	String evalString;
    	String acceptInput = "0123456789+-/*";
    	String theNumbers = "0123456789";
    	String theOperators = "+-/*";
    	
    	Queue<Object> outputQueue = new LinkedList<Object>();
    	
    	Stack<Character> operatorStack = new Stack<Character>();
    	Stack<Integer> priorityStack = new Stack<Integer>();
    	Stack<Object> outputStack = new Stack<Object>();
    	
    	String[] splitString;
    	
    	ArrayList<Integer> calcOperands = new ArrayList<Integer>();
    	ArrayList<Character> calcOperators = new ArrayList<Character>();
    	ArrayList<Integer> priorityList = new ArrayList<Integer>();
    	
    	int strLen;
    	int numOperands;
    	int numOperators;
    	
    	public StringCalculator(String inputString)
    	{
    		evalString = inputString;
    		splitString = evalString.split(" ");
    		strLen  = splitString.length;
    	}
    	
    	public boolean checkInput()
    	{
    		int x = 0;
    		
    		while(x < strLen)
    		{
    			if(acceptInput.contains(splitString[x]) == true)
    			{
    				x++;
    			}
    			else
    			{
    				return false;
    			}	
    			
    		}
    		return true;
    	}
    	
    	public boolean parseInput()
    	{
    		int x = 0;
    		while(x < strLen)
    		{
    			if(theNumbers.contains(splitString[x]))
    			{
    				calcOperands.add(Integer.parseInt(splitString[x]));
    			}
    			else if(theOperators.contains(splitString[x]))
    			{
    				calcOperators.add(splitString[x].charAt(0));
    			}
    			else
    			{
    				return false;
    			}
    			x++;
    		}
    		numOperands  = calcOperands.size();
    		return true;
    	}
    	
    	public boolean calculatePriority()
    	{
    		int x = 0;
    		char y;
    		numOperators = calcOperators.size();
    		while(x < numOperators)
    		{
    			y = calcOperators.get(x);
    			switch(y)
    			{
    			case '+': 
    			case '-': 
    				priorityList.add(x, 2);
    				break;
    			case '*':
    			case '/':
    				priorityList.add(x, 3);
    				break;
    			default: 
    				return false;
    		
    			}
    			x++;
    		}
    		return true;
    	}
    	
    	public boolean shuntingYard()
    	{
    		int x = 0;
    		int stackPriority = 0;
    		char tempOperator;
    		while(x < (numOperators))
    		{
    			outputQueue.add(calcOperands.get(x));
    			if((operatorStack.empty() != true)&&(priorityList.get(x) <= stackPriority))
    			{
    				outputQueue.add(operatorStack.pop());
    			}
    			operatorStack.push(calcOperators.get(x));
    			priorityStack.push(priorityList.get(x));
    			stackPriority = (Integer)priorityStack.pop();
    			x++;
    		}
    		
    		outputQueue.add(calcOperands.get(numOperands - 1));
    		while(operatorStack.empty() != true)
    		{
    			tempOperator = operatorStack.pop();
    			System.out.println(tempOperator);
    			outputQueue.add(tempOperator);
    		}
    		
    		/*for(int i = 0; i < outputQueue.size(); i++)
    		{
    			System.out.println(outputQueue.remove());
    		}*/
    
    		return true;
    	}
    	
    	public int calculateResult()
    	{
    		int queueLength = outputQueue.size();
    		int x = 0;
    		int output = 0;
    		Object currDigit;
    		while(x < queueLength)
    		{
    			currDigit = outputQueue.remove();
    			if(currDigit instanceof Integer)
    			{
    				outputStack.push(currDigit);
    			}
    			else if(currDigit == "+")
    			{
    				outputStack.push((Integer) outputStack.pop() + (Integer) outputStack.pop());
    			}
    			else if(currDigit == "-")
    			{
    				outputStack.push(((Integer) outputStack.pop() * -1) + (Integer) outputStack.pop());
    			}
    			else if (currDigit == "*")
    			{
    				outputStack.push((Integer) outputStack.pop() * (Integer) outputStack.pop());
    			}
    			else if (currDigit == "/")
    			{
    				outputStack.push((1/(Integer) outputStack.pop()) * (Integer) outputStack.pop());
    			}
    			x++;
    		}
    		output = (Integer) outputStack.pop();
    		return output;
    	}
    	
    	
    
    }
    
    


    and the main class that calls it is:

    package lab9;
    import java.io.Console;
    import java.util.Scanner;
    import java.util.concurrent.TimeUnit;
    
    public class ProjectCalculator 
    {
    	public static void main(String[] args)
    	{
    		String currChar = "";
    		String lastChar = "";
    		
    		Scanner scanner = new Scanner (System.in);
    		
    		int x = 0;
    		
    		System.out.println("Please enter your expression: ");
    		String inputString = scanner.nextLine();
    		
    		
    		
    		String[] splitString = inputString.split(" ");
    		int strLen = splitString.length;
    		
    		/*while(x < strLen)
    		{
    			lastChar = currChar;
    			currChar = splitString[x];
    			if((currChar == " ")&&(lastChar == " "));
    			{
    				System.out.println("Please enter an expression with only one space separating the terms");
    				try 
    				{
    					TimeUnit.SECONDS.sleep(5);
    				} 
    				catch (InterruptedException e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    				System.exit(1);
    			}
    			x++;
    		}*/
    		
    		StringCalculator StrCalc = new StringCalculator(inputString);
    		if(StrCalc.checkInput() == true)
    		{
    			StrCalc.parseInput();
    			StrCalc.calculatePriority();
    			StrCalc.shuntingYard();
    			System.out.println(StrCalc.calculateResult());
    		}
    		try 
    		{
    			TimeUnit.SECONDS.sleep(5);
    		} 
    		catch (InterruptedException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		System.exit(1);
    		
    	}
    
    }
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Britain
Interests:
Gaming
Anime
Game Development
Years Programming:
2
Programming Languages:
C++
C

Contact Information

E-mail:
Private

Friends

CountBale hasn't added any friends yet.

Comments

CountBale has no profile comments yet. Why not say hello?