Question

JAVA QUESTION I want to know how to combine different Shape objects in Java into one....

JAVA QUESTION

I want to know how to combine different Shape objects in Java into one. For example, if I wanted to make a class called CoffeeCup, and it was supposed to be a to go coffee cup, how would I combine a Rectangle, and two Ellipses (on the top and bottom) and then use that as one object in a different class?

Thank you in advance!

Homework Answers

Answer #1

There is no inbuilt feature of function in the JAVA to directly combine two shaped objects but you can do this by simply creating the shapes with the other shape like you will be combining the shapes based on their point of generation you need to know that where you need to start your shape and how you want to come by your next shape and then you need to provide the proper position and angle to your new shape so that it can look like it is combined with the first shape. This can be done easily as when you implement a shape you provide x axis and y axis co-ordinate along with the angle and using that details you can implement the second shape also to make the whole object look it is combined.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Hello I am having trouble answering these question and do not know how to do it....
Hello I am having trouble answering these question and do not know how to do it. please help!?? 1a.Central Perk coffee shop wanted to know how many customers they serve after 5pm. They have decided to collect data for four months, indicating the number of customers during these dates and they published the results in the table below. Number of Customers 0 10 20 30 40 50 60 Frequency 17 15 20 25 20 15 8 Probability P (x) Fill...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields and appropriate types and permissions diceType numSides sideUp The class should have A 0 argument (default) constructor default values are diceType: d6, numSides: 6, sideUp: randomValue 1 argument constructor for the number of sides default values are diceType: d{numSides}, sideUp: randomValue 2 argument constructor for the number of sides and the diceType appropriate accessors and mutators *theoretical question: can you change the number of...
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO...
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO YOU I NEED YOUR HELP PLEASE HELP ME. I WILL GIVE UPVOTE AND GOOD COMMENT THANK YOU SO MUCH !!! QUESTION 1 What is the output after the code executes? Assume there are no syntax errors and the code will compile. int x = 10; do { System.out.println ( x ); x -= 3; } while (x > 0); A. 10 7 4 1...
I know the answer to this is 83, but I have no idea how to do...
I know the answer to this is 83, but I have no idea how to do this question. Can you help give me an explanation why? Thank you! Refer to Table 10-5. If the government wanted to reduce pollution from 16 units to 6 units, which of the following fees per unit of pollution would achieve that goal? Table 10-5 The following table shows the marginal costs for each of four firms (A, B, C, and D) to eliminate units...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called keys with other objects called values. It is implemented as a Java class that uses arrays internally. 1. Theory. A map is a set of key-value pairs. Each key is said to be associated with its corresponding value, so there is at most one pair in the set with a given key. You can perform the following operations on maps. You can test if...
Someone posted from a discussion question..... Respond to the posted Economics has a big impact on...
Someone posted from a discussion question..... Respond to the posted Economics has a big impact on one's daily life. It affects the job you have, the wage you earn, the taxes you pay, the groceries and necessities you buy and the luxuries you may want. One big way it affects daily life is something we have all experienced with the pandemic, the supply chain. I had never given it much thought before Covid. If I wanted something, I would go...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Question 1 Case A Marty Ofori worked for a card company specializing in invitations and announcements....
Question 1 Case A Marty Ofori worked for a card company specializing in invitations and announcements. Every day for 25 years, he went to an office, sat at a desk, and took orders over the phone. He hated it. He was bored out of his mind. He didn’t know what to do. So he began skimming the business opportunities section of The Mirror. He wasn’t sure what he was looking for. At almost 50 years of age, he had few...
How do you relate the most to this story and why? In two strong paragraphs, explain...
How do you relate the most to this story and why? In two strong paragraphs, explain what it is about the tone and/or imagery of the story that speaks to you and why. Use some text examples to support your response Hills Like White Elephants (1927) The hills across the valley of the Ebro1 were long and white. On this side there was no shade and no trees and the station was between two lines of rails in the sun....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT