-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignments.java
More file actions
43 lines (32 loc) · 1.04 KB
/
Copy pathAssignments.java
File metadata and controls
43 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
Initially written by
@author Cay Hortsman BIG JAVA2
with major modificationn by Antonio Sanchez for
Cosc 20203 Programming Techniques
@version 1.05 2019-10-15
*/
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class Assignments {
Hashtable<String,Double> symbolTable = new Hashtable<String,Double>();
/**
* assigns the expression to the given variable, and stores this assignment into a hash table.
* @param line the String to be parsed for assigning an expression to a variable
*/
public void assignVar(String line) {
Scanner in = new Scanner(line);
EvaluatorVar e = new EvaluatorVar(symbolTable);
boolean execute = true;
while (in.hasNext())
{
String input = in.nextLine();
input = input.replaceAll("\\s+",""); // skipping blanks
Variable value = e.getAssignmentValue(input);
symbolTable.put(value.LHS,value.RHS); // direct Double casting
System.out.println( value.LHS + "=" + value.RHS);
}
}
}