2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle + Rectangle () + Rectangle (x: int, y:int) + setX (x: int) : void + getX(): int + sety (y: int) : void + getY(): int + computeArea(): int The class is called Rectangle, which contains on the following: (8 Marks) . Two instance variables x as the length and y as the width . Two constructors • Setter and getter methods for x and y . The method compute Area will return the rectangle's area (x*y) □ Add a main method. In the main method, create two objects and print their areas using compute Area method. 2. Write the Java code corresponding to the following UML diagram. -x: int -y: int Rectangle + Rectangle () + Rectangle (x: int, y:int) + setX (x: int) : void + getX(): int + sety (y: int) : void + getY(): int + computeArea(): int The class is called Rectangle, which contains on the following: (8 Marks) . Two instance variables x as the length and y as the width . Two constructors • Setter and getter methods for x and y . The method compute Area will return the rectangle's area (x*y) □ Add a main method. In the main method, create two objects and print their areas using compute Area method.
Expert 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
-
An airline company wants to create an online air ticket purchase for its customers. The company wants to attract customers to participate or purchase from its website by offering a discount to the...
-
In this assignment, you will create a program that allows theuser to draw in a window using brushes of different sizes andcolors. The user will be able to change the size and color of thebrush using...
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
Susan and Stan Collins live in Iowa, are married and have two children ages 6 and 10. In 2018, Susans income is $38,290 and Stans is $12,000 and both are self-employed. They also have $500 in...
-
Why are Alta Ind.s returns expected to move with the economy whereas Repo Mens are expected to move counter to the economy?
-
A piston cylinder hAs constant pressure of 2000 kPa with water at 20oC. It is now heated up to 100oC. Find the heat transfer and the entropy change using the steam tables. Repeat the calculation...
-
What are endorphins, and what causes cells in the brain to release them?
-
Preprah Engineering Contractors incurred service salaries and wages of $32,000 ($24,000 direct and $8,000 indirect) on an engineering project. The company applies overhead at a rate of 25% of direct...
-
What strategies can be employed to transform poorly formulated questions into effective ones that promote constructive dialogue and deeper inquiry?
-
Tree Seedlings has the following current-year purchases and sales for its only product. Date January 1 January 3 February 14 February 15 June 30 November 6 November 19 Activities Beginning inventory...
-
Give some idea how someone combine or apply an Intercultural competencies perspective to other field of studies like linguistics, business management.
-
How do protagonists in metafictional works and narrative experiments break the fourth wall, blurring the boundaries between fiction and reality, and inviting readers to participate in the...
-
Using the McNaughton-Yamada-Thompson Algorithm, construct an NFA from the regular expression (= {0, 1}): 0((0|1)*1)*1 a) Draw a state graph for the NFA. b) Construct the state transition table for...
-
Diagram a calorie counting program that calculates the total weekly calories for breakfast. The diagram should allow the user to input the number of calories consumed each day for seven days, then...
-
How do protagonists in Bildungsroman and coming-of-age narratives undergo psychological and moral growth, grappling with the challenges of self-discovery, autonomy, and individuation as they...
-
2. For each of the instructions highlighted (boldface), derive the effective address of the memory variable (source) if any memory variable is involved, and the contents of the register a or d...
-
Let z(x, y) =xy where x= r cos(-40) a y = r sin( - 80). z ???? ar ar' 80 20 20 Calculate z 20 z ar = & Note: To produce the symbol, type the word "theta". z ar by first finding & and using the...
-
Listed below are several terms and phrases associated with basic assumptions, broad accounting principles, and constraints. Pair each item from List A (by letter) with the item from List B that is...
-
Write code to change the second elements value to "IS", producing the following ArrayList as the result: ["It", "IS", "a", "dark", "and", "stormy", "night"]
-
Write a method called printPowersOfN that accepts a base and an exponent as arguments and prints each power of the base from base 0 (1) up to that maximum power, inclusive. For example, consider the...
-
Write a recursive method called doubleDigits that accepts an integer n as a parameter and returns the integer obtained by replacing every digit of with two of that digit. For example,...
-
How might planning in a not-for-profit organization such as the World Wildlife Fund differ from planning in a for-profit organization such as Airbnb?
-
Provide examples of the sources of data a residential solar panel company might gather when engaging in environmental scanning. Exhibit 8-6 may be helpful when answering this question.
-
How supportive do you think Teslas production staff is of the objective to produce 20 million electric vehicles in 2030? Would it have a positive or negative impact on morale? Explain.
Study smarter with the SolutionInn App