-
Notifications
You must be signed in to change notification settings - Fork 0
/
Factor.java
58 lines (37 loc) · 1.3 KB
/
Factor.java
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
import java.util.List;
import java.util.Iterator;
import java.util.LinkedList;
//an expression which is designated to be multiplied with another factor instance
abstract class Factor implements Comparable{
protected OperationList operations; //the factor that comes after the operation is stored as an operational factor
protected char nextOperation;
protected boolean sign = true;
protected StringBuilder valueMask;
public Factor(){
operations = new OperationList();
}
public static Factor deepCopy(Factor f){
System.out.println("Factor.deepCopy(), "+f+" is a: " +f.getClass());
if(f instanceof Expression)
return new Expression((Expression)f);
else if(f instanceof Variable)
return new Variable((Variable) f);
else if(f instanceof Constant)
return f;
else
throw new IllegalArgumentException("Weird type given for Factor...");
}
/*
For parsing exponent, its going to be parsed in a temp "factory"
the f
*/
//this might just be for organization but what properties can i give factor?
final void addOperation(char c, Factor f){
if(operations == null)
operations = new OperationList();
operations.add(c,f);
}
final OperationList operations(){
return operations;
}
}