Open-Closed Principle (OCP), Dependency Inversion Principle (DIP) Explain. 2. Here is an example of Java code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Open-Closed Principle (OCP), Dependency Inversion Principle (DIP) Explain. 2. Here is an example of Java code that violates two SOLID principles. public interface Shape { public void draw(); wwwwwww public void resize (int width, int height); } public class Circle implements Shape { public void draw() { } System.out.println("Drawing a circle..."); wwwwww } } public void resize (int width, int height) { System. out.println("Resizing the circle..."); wwwwwwwmmmmm wwwwwwwmmm public class Square implements Shape { public void draw() { wwwwwww System.out.println("Drawing a square..."); } public void resize (int width, int height) { wwwwww System.out.println("Resizing the square..."); } public void rotate (int angle) { System.out.println("Rotating the square by " + angle + degrees..."); "1 Second Question (a) This code violates ISP because Second Question (b) What is the other SOLID violation? Open-Closed Principle (OCP), Dependency Inversion Principle (DIP) Explain. 2. Here is an example of Java code that violates two SOLID principles. public interface Shape { public void draw(); wwwwwww public void resize (int width, int height); } public class Circle implements Shape { public void draw() { } System.out.println("Drawing a circle..."); wwwwww } } public void resize (int width, int height) { System. out.println("Resizing the circle..."); wwwwwwwmmmmm wwwwwwwmmm public class Square implements Shape { public void draw() { wwwwwww System.out.println("Drawing a square..."); } public void resize (int width, int height) { wwwwww System.out.println("Resizing the square..."); } public void rotate (int angle) { System.out.println("Rotating the square by " + angle + degrees..."); "1 Second Question (a) This code violates ISP because Second Question (b) What is the other SOLID violation?
Expert Answer:
Answer rating: 100% (QA)
The code snippet provided in the images is violating two SOLID principles the Interface Segregation ... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Here is an example of the Battle of the Sexes game discussed in the text. Two people, let us call them Michelle and Roger, although they greatly enjoy each others company, have very different tastes...
-
Refer to the information in Exercise 16-11. Using the direct method, prepare the statement of cash flows for the year ended June 30, 2017. IKIBAN INC. Comparatlve Balance Sheets June 30, 2017 and...
-
An ASTM grade 40 cast iron has the following result from testing for ultimate tensile strength: Sut = W [27.7, 46.2, 4.38] kpsi. Find the mean and standard deviation of Sut, and estimate the chance...
-
Find the width of a river at points A and B if the angle BAC is 90, the angle ACB is 40, and the distance from A to C is 75 feet. See Fig. 6. B A Figure 6 75 C
-
Using your favorite operating system, write code to spawn a process that writes Hello, world to the screen or flashes an LED, depending on your available output devices.
-
On December 1, 2017, Fullerton Company had the following account balances. During December, the company completed the following transactions. Dec. 7 Received $3,600 cash from customers in payment of...
-
In the context of port design and operations, what specific environmental sustainability measures or practices do you think should be integrated into the planning and management of ports to mitigate...
-
Hemming Company reported the following current-year purchases and sales for its only product. Date January 11 January 10 Activities Beginning inventory Units Acquired at Cost $13.80- Sales March 14....
-
Juliana is considering four saving plans for her future. Each savings plan gives a different interest rate. She plans to save RM 3,500 each year for 10 years. With the savings, she plans to withdraw...
-
For the bolted connection shown in Figure, Compute the design strength ftPn, neglecting block shear. The angle is made of A36 steel (fy-36 ksi, fu-58 ksi) The bolts are 1 in diameter. Assume U=0.9 +...
-
Sound waves create a physiological response in which the brain interprets the sound waves and correlates those with a meaning. What is this passive process known as?
-
What is the thesis of the essay Free Minds and Hearts at work? What support to the thesis? And why agree or disagree? Explain
-
A popular product is available on Amazon and Walmart for $50. Local specialty stores in big cities sell the same product for $100. Can Target advertise the product online by saying "$100 elsewhere...
-
3. Describe in words the motion of the servo caused by the code below. Note it may be helpful to setup your own servo and run the code to see what happens. #include Servo myservo; int pos = 0; void...
-
Based on the following sensitivity report, what would be the impact of changing the objective function coefficient for Product_1 to 12 and changing the objective function coefficient for Product_3 to...
-
Identify the Critical Infrastructure Physical Protection System Plan.
-
In an array heap as implemented in this section, for the element at index 8 of the array, what are the indexes of its left and right children? What is the index of its parent? If the element is at...
-
What output is produced by the following program? public class MysterySoda { public static void main (String[] args) { String soda "Coke"; %3D 4 String pop "Pepsi"; String Coke "p"; %3D String Pepsi...
-
Write a method called writeSequence that accepts an integer n as a parameter and prints to the console a symmetric sequence of n numbers composed of descending integers that ends in 1, followed by a...
-
Preventing a user who approves a configuration change from being the person who implements the change is an example of which of the following? A. Rotation of duties B. Least privilege C. Segregation...
-
A onedimensional heat conduction problem can be expressed by the following differential equation: where \(k\) is the thermal conductivity, \(T(x)\) is the temperature, and \(Q\) is heat generated per...
-
Consider a simply supported beam of length \(L\) subjected to a uniformly distributed transverse load \(p(x)=p_{0}\). Use the Rayleigh-Ritz method to determine the transverse deflection \(v(x)\) of...
Study smarter with the SolutionInn App