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
Java program question! If I pass null to a method, how can I use the passed...
Java program question! If I pass null to a method, how can I use the passed value to compare. Here is example code, it might be wrong, please make it could run on eclipse. Public class hw{ public static void main (String args[]) { method1(); } private static void method1() { System.out.println(method(null)); } public static String method(int[] a) { return null; } What I want to get in the output is just "()". It is not just to type the...
I am working on a JSON WPF program-C#... I have 2 objects that I am concatenating....
I am working on a JSON WPF program-C#... I have 2 objects that I am concatenating. All I need to know is how to format the first block of code to where the data types match. Here is what I have: I need to take this: A.) { “Name” : “Walder” , “Alias” : “Hodor” , “Alliance” : “House Stark” } and this: B.) { “Name” : “Margaery Tyrell” , “Alias” : [ “The Little Queen”, “The Little Rose”, “Maid...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different implementation. Each symbol table will contain as a key a word read from a text file and as a value the number of times that word occurs in the text file. Have the program fill the first symbol table with these counts, keeping track of how long that takes using a Stopwatch object. It then does the same thing with the second symbol table....
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...
SIMPLE PAINTING GUI APP in Java Your mission in this exercise is to implement a very...
SIMPLE PAINTING GUI APP in Java Your mission in this exercise is to implement a very simple Java painting application. Rapid Protyping The JFrame app must support the following functions: (you can use any other programming languages that you are comfortable)  Draw curves, specified by a mouse drag.  Draw filled rectangles or ovals, specified by a mouse drag (don't worry about dynamically drawing the shape during the drag - just draw the final shape indicated).  Shape selection...
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...
I don't know how to write (iii) and want to make sure my answer is right...
I don't know how to write (iii) and want to make sure my answer is right for (i) and (ii) A prize competition operates by a machine choosing randomly (no replacement) 3 balls from 18. There are 6 red balls, 6 blue balls and 6 green balls. And for each colour the balls are numbered 1,2,3,4,5,6. There are three ways you can win: (C) you have three balls the same colour; (T) you have “top scores” meaning that the three...
I understand how to implement this in one file, but I'd love to see it as...
I understand how to implement this in one file, but I'd love to see it as in the Directions here into 3 files.as an example. Thank you! Direction: Create class having separate executable file, header file and implementation file. Write class with appropriate constructors to initialize the values of member variables. Create a card game called flash card using class data structure when each player draws three cards for random numbers (1-4) as Diamond, Spade, Clubs and Hearts respectively and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT