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!
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.
Get Answers For Free
Most questions answered within 1 hours.