forked from Sukhdev841/Numerical-Methods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths_variable_table.java
More file actions
56 lines (50 loc) · 1.09 KB
/
Copy paths_variable_table.java
File metadata and controls
56 lines (50 loc) · 1.09 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
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.*;
public class s_variable_table
{
public List<String> var_names ;
public List<String> var_values ;
public int count = 0;
public s_variable_table()
{
var_names = new ArrayList<String>();
var_values = new ArrayList<String>();
}
public void add_variable(String variable,String value)
{
for(int i=0;i<count;i++)
{
if(var_names.get(i).equals(variable))
{
var_values.set(i,value);
return;
}
}
var_names.add(variable);
var_values.add(value);
count++;
}
public boolean exist(String variable)
{
if(var_names.contains(variable))
return true;
return false;
}
public String valueOf(String variable)
{
for(int i=0;i<count;i++)
{
if(var_names.get(i).equals(variable))
return var_values.get(i);
}
return null;
}
public void print()
{
System.out.println("-----------------------------");
for(int i=0;i<count;i++)
{
System.out.println(var_names.get(i)+" = "+var_values.get(i));
}
System.out.println("-----------------------------");
}
}