NEED IT BY TOMMOROW
Top of Form QUESTION 2) a) Identify the cohesive behavior for the following program and justify your answer. b). If you think that the program is an example of bad application design, write down the modified code that satisfies the properties of a good design. public class Purchase { public void ConnectToSite(){ System.out.println("Inside ConnectToSite"); } public void SelectItems(){ System.out.println("Inside SelectItems"); } public void ProceedToPayment(){ System.out.println("Inside ProceedToPayment"); } public void CloseConnection(){ System.out.println("Inside CloseConnection"); } public static void main(String[] args) { Purchase myPurchase = new Purchase(); myPurchase.ConnectToSite(); myPurchase.SelectItems(); myPurchase.ProceedToPayment(); myPurchase.CloseConnection(); } } Top of Form QUESTION 3) a) What are the characteristics of Unified Process? Describe the four phases of Unified Process. b) Design reusability is handled differently in Extreme Programming than in other conventional approaches. Explain how this occurs. [1+2+1.5=4.5 Marks] Topic ) What are the characteristics of Unified Process? Describe the four phases of approaches. Explain how this occurs. [1+2 + QUESTION 4 a. Why is it important to consider refactoring when modifying existing class/classes? b. After completely refactoring a class, some of the unit tests may fail. Briefly discuss why maintaining a bank of unit tests and running these regularly is important for the refactoring process. [2 + 1 = 3 Marks ]1.5=4.5 Marks]2 - Requirements Analysis - Inheritance Topic 3 - Use Cases and Polymorphism Topic 4 – Domain models, sequence diagrams and interfaces QUESTION5 The following PhoneDiary class has three public data members: i. ContactName: a String type data member ii. Setter method: setName(string) iii. Getter method: getName The setName sets the name to ContactName after checking that the input parameter is not null. On the other hand, the gertName method return ContactName if it is not null, otherwise returns “Not Initialized” Identify the coupling behavior for the following program and justify your answer. If you think that the following program is an example of a bad application design, write down the modified code that satisfies the properties of a good design. public class PhoneDiary { public String ContactName; public String getName(){ if(ContactName==null) return "Not initialized"; else return ContactName; } public void setName(String Nm){ if(Nm!=null) this.ContactName=Nm; else System.out.println("Name cannot be initialized to a null"); } } public class Process { public static void main(String[] args) { PhoneDiary pd=new PhoneDiary (); pd.ContactName=null; System.out.println("Name is "+ pd.ContactName); } } [3+3=6 Marks] Types and Lecture Test StuQUESTION 6 The following questions relate to the Calculator class provided below: (a) Identify one (1) bad smell in the Calculator class and explain why this is an issue. How can this bad smell be removed? (b) Rewrite the Calculator class to demonstrate the removal of the bad smell identified in part (a). You only need to rewrite the section that requires modification. public class Calculator { public void calculate (double value1, double value2, char operation) { double result = 0; boolean isError = false; if (operation == '+') result = value1 + value2; else if (operation == '-') result = value1 - value2; else if (operation == '*') result = value1 * value2; else if (operation == '/') { if (value2 == 0) { System.out.println ("Error: Unable to divide by 0!"); isError = true; } else result = value1 / value2; } if (!isError) { System.out.println ("Calculation Results: "); System.out.println ("====================="); System.out.println (value1 + " " + operation + " " + value2 + " = " + result); } } } [2+5 = 7 Marks] Question 7 Consider your university/campus library and imagine about the workflow of the library. A student can borrow/rent items from the library. Once the items are selected, a one-time checkout session is created to issue the invoice. Now consider the following class diagram with important entities of the system. Based on the properties of the system, the relationship between the classes can be aggregation, multiplicity, composition, association, generalization, etc. Based on the above description, find out the appropriate values for: A (relation between Student and Library Invoice) B (relation between Checkout Session and Library invoice) C (relation between Library Item and Library Invoice) D (relation between actual items and Library Item class) In addition, you have to write down the reason in brief for selecting that property. Bottom of Form dy Resources Course Media Gallery QUESTION 8 The code snippets below provide some of the contents of two classes: Fruit and Passion. public class Fruit { … public String toString() { return “From Fruit Class”; } } public class Passion extends Fruit { … public String toString() { return “From Passion Fruit Class”; } } In this scenario, consider the following four pairs of statements (Object Declaration + Print), where one of the pairs is incorrect. Find out that one and discuss the reason. For the other three pairs, write down the answers and briefly discuss the reason. // pair-1 Fruit f1 = new Fruit(); System.out.println(f1.toString()); // pair-2 Fruit f2 = new Passion(); System.out.println(f2.toString()); // pair-3 Passion f3 = new Passion(); System.out.println(f3.toString()); // pair-4 Passion f4 = new Fruit(); System.out.println(f4.toString()); [2 x 4 = 8 Marks] QUESTION 9 Consider the following Sort class: public class Sort { public double[] Sort3 (double value1, double value2, double value3) { double sorted[]=new double[3]; if (value1 >= value2 && value1 >= value3){ sorted[2] = value1; // stores the largest value in the final index if (value2 <= value3){ ="" ="" sorted[0]="value2;" stores="" the="" smallest="" value="" in="" the="" first="" index="" ="" sorted[1]="value3;" stores="" the="" middle="" value="" in="" the="" middle="" index="" ="" ="" ="" }="" ="" ="" ="" else{="" ="" sorted[0]="value3;" ="" sorted[1]="value2;" ="" ="" ="" } ="" ="" ="" } ="" ="" ="" ="" ="" else="" if="" (value2="">= value1 && value2 >= value3) { sorted[2]= value2; if (value1 <= value3){="" ="" sorted[0]="value1;" ="" sorted[1]="value3;" ="" ="" ="" }="" ="" ="" ="" else{="" ="" sorted[0]="value3;" ="" sorted[1]="value1;" ="" ="" ="" }="" ="" }="" ="" else="" {="" ="" ="" ="" sorted[2]="value3;" ="" ="" ="" if="" (value2="">=><= value1){ sorted[0] = value2; sorted[1] = value1; } else{ sorted[0] = value1; sorted[1] = value2; } } return sorted; // returns the sorted number in an array of 3 doubles } } the method sort3 of the class sort takes 3 (three) numbers as input and return the numbers in an array in the sorted. for example, if the inputs are 5,3,8, the output will be [3,5,8]. write 5 (five) unit tests for the above class to test calculate method. note that all the unit tests should address distinctscenarios. [1.5x5 = 7.5 marks] itech 3000/7000 atmc - sydney itech 5402 sem8 2020 atmc - sydney itech 7201 sem8 2020 atmc - sydney itech 7401 sem8 2020 atmc - sydney itech 7409 sem8 2020 atmc - sydney turnitin access 2020 course menu value1){="" ="" sorted[0]="value2;" ="" sorted[1]="value1;" ="" ="" ="" }="" ="" ="" ="" else{="" ="" sorted[0]="value1;" ="" sorted[1]="value2;" ="" ="" ="" }="" ="" ="" }="" ="" return="" sorted;="" returns="" the="" sorted="" number="" in="" an="" array="" of="" 3="" doubles="" }="" }="" the="" method="" sort3="" of="" the="" class="" sort="" takes="" 3="" (three)="" numbers="" as="" input="" and="" return="" the="" numbers="" in="" an="" array="" in="" the="" sorted.="" for="" example,="" if="" the="" inputs="" are="" 5,3,8,="" the="" output="" will="" be="" [3,5,8].="" write="" 5="" (five) unit="" tests for="" the="" above="" class="" to="" test="" calculate="" method.="" note="" that="" all="" the="" unit="" tests="" should="" address distinctscenarios.="" [1.5x5="7.5" marks]="" itech="" 3000/7000="" atmc="" -="" sydney="" itech="" 5402="" sem8="" 2020="" atmc="" -="" sydney="" itech="" 7201="" sem8="" 2020="" atmc="" -="" sydney="" itech="" 7401="" sem8="" 2020="" atmc="" -="" sydney="" itech="" 7409="" sem8="" 2020="" atmc="" -="" sydney="" turnitin="" access="" 2020="" course="">= value1){ sorted[0] = value2; sorted[1] = value1; } else{ sorted[0] = value1; sorted[1] = value2; } } return sorted; // returns the sorted number in an array of 3 doubles } } the method sort3 of the class sort takes 3 (three) numbers as input and return the numbers in an array in the sorted. for example, if the inputs are 5,3,8, the output will be [3,5,8]. write 5 (five) unit tests for the above class to test calculate method. note that all the unit tests should address distinctscenarios. [1.5x5 = 7.5 marks] itech 3000/7000 atmc - sydney itech 5402 sem8 2020 atmc - sydney itech 7201 sem8 2020 atmc - sydney itech 7401 sem8 2020 atmc - sydney itech 7409 sem8 2020 atmc - sydney turnitin access 2020 course menu>=>