Software Engineering Assignments

Verified

Added on  2019/09/21

|5
|676
|187
Report
AI Summary
The assignment content discusses Java programming concepts, including condition coverage and path coverage testing. It also touches on topics such as divergent change, shotgun surgery, and the differences between inheritance and delegation in object-oriented programming.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Question 2)
1. public static void main(string args[]){
2. float x,y; int a,b;
3. read(x);
4. read(y);
5. if((x == 0) ||(y>0))
6. y = y/x;
7. else x = y+2;
8. system.out.println(x);
9. system.out.println(y);
10. call addition(a,b);
11. }
12. Public void addition(int a, int b){
13. System.out.println(a+b);
14. }
1. Set of test cases for the condition coverage
Test Case 1: x = 0 y = 2s // true
Test Case 2: x = 5 y = -2 // false
2. Set of test cases for the path coverage
Test Case: a = 10 b = 20

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Document Page
Question 3)
Ans a): Divergent change seems like Shotgun Surgery but there is a little difference. Divergent
Change is followed when there are many changes are to made in a single class whereas Shotgun
Surgery refers to when a single change is to made in multiple classes simultaneously.
Ans b):
(A & B & C)
F
T F
T T F
T T T
(A & B & ! C)
F
T F
T T !T = (F)
T T !F = (T)
(A & !B & C)
F
T !T = F
T !F = T F
T !F = T T
(A & !B & !C)
F
T !T = F
T !F = T !T = F
T !F = T !F = T
Document Page
(!A & B & C)
!T = F
!F = T F
!F = T T F
!F = T T T
(!A & B & !C)
!T = F
!F = T F
!F = T T !T = F
!F = T T !F = T
(!A & !B & C)
!T = F
!F = T !T = F
!F = T !F = T F
!F = T !F = T T
(!A & !B & !C)
!T = F
!F = T !T = F
!F = T !F = T !T = F
!F = T !F = T !F = T
Upgraded Code:
If (A & B & C) then Result = Action1
Else Result = Action0
If (A & B & !C) then Result = Action1
If (A & !B & C) then Result = Action1
If (A & !B & !C) then Result = Action1
If (!A & B & C) then Result = Action1
If (!A & B & !C) then Result = Action0
If (!A & !B & C) then Result = Action0

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
The existing code is replaced by new design of code.
Ans c:
It could be a reason that when we renaming a method with new name
but we forget that this new name is already used (It could be
variable name, method name) this will create a big problem in code.
Ans d:
Class Stack is extending Vector class.
I have a child class that uses only one portion of the methods of
its superclass.
So to convert inheritance to delegation a field is created and this
is uses a superclass object in it, delegate methods to the parent
class object to avoid inheritance.
Image one: showing inheritance
Image two: showing delegation
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]