0% found this document useful (0 votes)
837 views

Lab - Weighted Composite Complexity Measure - Answer

The document discusses calculating complexity of an object-oriented program using the Weighted Composite Complexity (WCC) measure. It provides a code sample and asks to identify tokens, complete a table with complexity values, and calculate the overall WCC value.

Uploaded by

pwasana99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
837 views

Lab - Weighted Composite Complexity Measure - Answer

The document discusses calculating complexity of an object-oriented program using the Weighted Composite Complexity (WCC) measure. It provides a code sample and asks to identify tokens, complete a table with complexity values, and calculate the overall WCC value.

Uploaded by

pwasana99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

BSc (Hons) in Information Technology

Year 4

Lab Exercise – Weighted Composite Complexity Measure


IT4100 - SQA Semester 1

The objective of this lab is to learn how to calculate the complexity of an object-oriented program using
the Weighted Composite Complexity (WCC) measure.

Question 1
Consider the following code segment and answer the questions given below:
public class DeamonThread extends Thread {
public static void main(String[] args) {
System.out.println("Entering main Method");
DeamonThread t = new DeamonThread();
int number =10;
t.setDaemon(true);
t.start();
try{
if(number == 10)
Thread.sleep(3000);
}catch(InterruptedException x){}
System.out.println("Leaving main method");
}

public void run(){


System.out.println("Entering run method");
try{
System.out.println("CurrentThread()is" + Thread.currentThread().getName());
while(true){
try{
Thread.sleep(500);
System.out.println("In run method: woke up again");
}catch(InterruptedException x) {
x.printStackTrace();
}
}
}
}
}

1
BSc (Hons) in Information Technology
Year 4

Lab Exercise – Weighted Composite Complexity Measure


IT4100 - SQA Semester 1

a) List down the tokens that could be identified under the size factor of the WCC measure. Separate the
tokens using a comma.
Program Statements Tokens
public class DeamonThread extends Thread {

public static void main(String[ ] args) { void, main ( )

System.out.println("Entering main Method"); System, . ,out, ., println(), "Entering main Method"

DeamonThread t = new DeamonThread( ); DeamonThread , t , = , new, DeamonThread( )

int number =10; int , number , = , 10

t.setDaemon(true); t , . , setDaemon( ), true

t.start(); t , . , start( )

try {

if(number == 10) if ( ), number, ==, 10

Thread.sleep(3000); Thread , . ,sleep( ), 3000

}catch (InterruptedException x) {} catch ( ), InterruptedException , x

System.out.println("Leaving main method"); System , . , out , . ,println( ) ,"Leaving main method"

public void run() { void , run( )

System.out.println("Entering run method"); System , . , out , . , println( ), "Entering run method"

try {
System , . , out , . , println( ), "CurrentThread() is" , +,
System.out.println("CurrentThread() is" + Thread.currentThread().getName()); Thread , . , currentThread(), . , getName()

while(true){ while( ) , true

try{

Thread.sleep(500); Thread , . ,sleep( ), 500


System , . , out , . ,println( ) ,"In run method: woke up
System.out.println("In run method: woke up again");
again"
} catch (InterruptedException x) { catch ( ), InterruptedException , x

x.printStackTrace(); x , . , printStackTrace()

2
BSc (Hons) in Information Technology
Year 4

Lab Exercise – Weighted Composite Complexity Measure


IT4100 - SQA Semester 1

b) Complete the following table by identifying the values of S, Wn, Wi, Wc, Wt ,WC, and WCC.
Line No Program Statements S Wn Wi Wc Wt WC
1 public class DeamonThread extends Thread {

2 public static void main(String[ ] args) { 2 0 2 0 2 4

3 System.out.println("Entering main Method"); 6 0 2 0 2 12

4 DeamonThread t = new DeamonThread( ); 5 0 2 0 2 10

5 int number =10; 4 0 2 0 2 8

6 t.setDaemon(true); 4 0 2 0 2 8

7 t.start(); 3 0 2 0 2 6

8 try {

9 if(number == 10) 4 1 2 1 4 16

10 Thread.sleep(3000); 4 1 2 0 3 12

11 }catch (InterruptedException x) {} 3 0 2 0 2 6

12 System.out.println("Leaving main method"); 6 0 2 0 2 12

13 }

14 public void run() { 2 0 2 0 2 4

15 System.out.println("Entering run method"); 6 0 2 0 2 12

16 try {

17 System.out.println("CurrentThread() is" + Thread.currentThread().getName()); 12 0 2 0 2 24

18 while(true){ 2 1 2 2 5 10

19 try{

20 Thread.sleep(500); 4 1 2 0 3 12

21 System.out.println("In run method: woke up again"); 6 1 2 0 3 18

22 } catch (InterruptedException x) { 3 1 2 0 3 9

23 x.printStackTrace(); 3 1 2 0 3 9

24 }

25 }

26 }

27 }

28 }

WCC Value ( 192

You might also like