forked from dreamer-89-zz/complexity-measure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Decision_Table_Testing.java
217 lines (214 loc) · 7.81 KB
/
Decision_Table_Testing.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package software_testing_meaures;
import java.util.Random;
import java.util.Scanner;
/**
*
* @author Gaurav Kumar Shah
*/
class Decision_Table_Testing {
static String conditions[][] = new String[11][11];
static StringBuffer sb = new StringBuffer();
static int numberer;
static String[] stubs = new String[]{"C1: x<y+z","C2: y<x+z","C3: z<x+y","C4: x=y","C5: y=z","C6: z=x","A1: Not a Triangle",
"A2: Equilateral Triangle","A3: Isoceles Triangle","A4: Scalene Triangle","A5: Impossible"};
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
char choice;
do
{
numberer = 1;
System.out.print("\nDecision Table Testing\n");
System.out.println("\nTESTCASE X Y Z OUTPUT");
generateOutputEquivalence();
setImpossibleActionEntry();
System.out.println();
System.out.println("\nDECISOIN TABLE\n");
printDecisionTable();
System.out.println("\nDo you want to continue(y/n) ? ");
choice = s.next().charAt(0);
System.out.println();
}while(choice=='Y'||choice=='y');
}
public static void printDecisionTable()
{
for(int i=0;i<11;i++)
{
System.out.printf("%-25s", stubs[i]);
for(int j=0;j<11;j++)
System.out.printf("%2s ",conditions[i][j]);
System.out.println("");
}
}
public static void setImpossibleActionEntry()
{
int im[] = new int[]{4,5,7};
int row[] = new int[]{5,4,3};
for(int i =0;i<im.length;i++)
for(int j =0;j<6;j++)
conditions[j][im[i]] = "1";
for(int i =0;i<im.length;i++)
conditions[10][im[i]] = "*";
for(int i =0;i<3;i++)
conditions[row[i]][im[i]] = "0";
}
public static void generateOutputEquivalence()
{
Random m = new Random();
int number=11,x,y,z;
boolean executed[] = new boolean[11];
boolean condition1,condition2,condition3,c4,c5,c6;
int range = 100,i,j;
for(i =0;i<11;i++)
for(j =0;j<11;j++)
conditions[i][j]="";
while(number>0)
{
condition1 = condition2 = condition3 = false;
x = m.nextInt(range);
y = m.nextInt(range);
z = m.nextInt(range);
if(x>y+z)
{
condition1=true;
if(!executed[0])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Not a Triangle");
conditions[0][0] = "0";
for(j=1;j<6;j++)
conditions[j][0] = "-";
executed[0]=true;
number--;
conditions[6][0] = "*";
}
}
if(y > x+z)
{
condition2 = true;
if(!executed[1])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Not a Triangle");
conditions[0][1] = "1";
conditions[1][1] = "0";
for(j=2;j<6;j++)
conditions[j][1] = "-";
executed[1]=true;
conditions[6][1] = "*";
number--;
}
}
if(z > x+y)
{
condition3 = true;
if(!executed[2])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Not a Triangle");
for(j=0;j<2;j++)
conditions[j][2] = "1";
conditions[2][2] = "0";
for(j=3;j<6;j++)
conditions[j][2] = "-";
executed[2]=true;
conditions[6][2] = "*";
number--;
}
}
if(!condition1 && !condition2 && !condition3 )
{
if(x==y && y==z && x==z)
{
if(!executed[3])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Equilateral ");
for(j=0;j<6;j++)
conditions[j][3] = "1";
executed[3]=true;
conditions[7][3] = "*";
number--;
}
// Make impossible Entries.
else if(!executed[4])
{
System.out.printf("\n%-9d %-3s %-3s %-3s %-30s",numberer++,"X","X","X","Impossible");
//System.out.println()
executed[4] = true;
number--;
}
else if(!executed[5])
{
System.out.printf("\n%-9d %-3s %-3s %-3s %-30s",numberer++,"X","X","X","Impossible");
executed[5] = true;
number--;
}
else if(!executed[7])
{
System.out.printf("\n%-9d %-3s %-3s %-3s %-30s",numberer++,"X","X","X","Impossible");
executed[7] = true;
number--;
}
}
else if(x==y && y!=z && x!=z)
{
if(!executed[6])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Isosceles ");
for(j=0;j<4;j++)
conditions[j][6] = "1";
for(;j<6;j++)
conditions[j][6] = "0";
conditions[8][6] = "*";
executed[6]=true;
number--;
}
}
else if(x!=y && y==z && x!=z)
{
if(!executed[8])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Isosceles ");
executed[8]=true;
for(j=0;j<6;j++)
conditions[j][8] = "1";
conditions[8][8]="*";
conditions[3][8] = "0";
conditions[5][8] = "0";
number--;
}
}
else if(x!=y && y!=z && x==z)
{
if(!executed[9])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Isosceles ");
executed[9]=true;
for(j=0;j<6;j++)
conditions[j][9] = "1";
conditions[3][9] = "0";
conditions[4][9] = "0";
conditions[8][9] = "*";
number--;
}
}
else if(x!=y && y!=z && x!=z)
{
if(!executed[10])
{
System.out.printf("\n%-8d %3d %3d %-4d %-30s",numberer++,x,y,z,"Scalene ");
executed[10]=true;
for(j=0;j<3;j++)
conditions[j][10] = "1";
for(;j<6;j++)
conditions[j][10] = "0";
conditions[9][10] = "*";
number--;
}
}
}
}
}
}