-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClause.java
More file actions
50 lines (46 loc) · 1.22 KB
/
Clause.java
File metadata and controls
50 lines (46 loc) · 1.22 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
/******************************************************************************
* File: Clause.java
* Author: Keith Schwarz (htiek@cs.stanford.edu)
*
* A class representing a clause in a 2SAT formula. Each clause a disjunction
* of two literals.
*/
public final class Clause<T> {
private final Literal<T> mOne; // The two literals this clause is made of.
private final Literal<T> mTwo;
/**
* Constructs a new clause out of two literals.
*
* @param one The first literal
* @param two The second literal
*/
public Clause(Literal<T> one, Literal<T> two) {
mOne = one;
mTwo = two;
}
/**
* Returns the first literal in this clause.
*
* @return The first literal in this clause.
*/
public Literal<T> first() {
return mOne;
}
/**
* Return the second literal in this clause.
*
* @return The second literal in this clause.
*/
public Literal<T> second() {
return mTwo;
}
/**
* Returns a string representation of this clause.
*
* @return A string representation of this clause
*/
@Override
public String toString() {
return "(" + first() + " or " + second() + ")";
}
}