Determine if any of the circles overlap the triangle

Assignment Help Computer Engineering
Reference no: EM132198042

Write an error-free Java program to do the following things. The program is modeled on a simple game where shapes move around the screen and if they overlap, then one of them gets "swallowed". In this case, the triangle shape swallows any circle that comes close to its center.

Use a Shape2D class that has only private data members. The data members should be floating point (decimal) numbers that represent the (x, y) coordinates of the center of the shape as well as at least one data member that corresponds to size of the object.

There should be a Circle class that inherits from Shape2D and a Triangle class that inherits from Shape2D. In general, put whatever methods/data that can be used by all (2D) shapes in the superclass and put Triangle/Circle specific methods/data into the subclass.

The main program should have three circle objects and one triangle. The circles start with radius = 1 and location at origin. The triangle starts with base of 2 and a height of 3.5 (use a constructor).

Input from the user a (new) radius for each circle. The radii will correspond to small, med, large circles. Input from the user a location of the triangle. Set the data members (instance variables) of the circles and triangle based on the user input.

To simulate the game, we would move the circles over time and determine if they intersect the triangle. For this program, move the small circle left by .75, move the medium circle up by 1.3 and move the large circle at a -45 degree angle a distance of .7071 from the origin.

Determine if any of the circles overlap the triangle. We will define overlap as the positions of the objects are within 0.5 of each other. If one or more circles overlap the triangle, make the triangle better by increasing the base and height of the triangle by a scale factor equal to the area of the circle. For example, if the area of the circle is 2.5 then the base and height of the triangle are multiplied by 2.5. The radius of the overlapping circle should be set to 0 and its location set to the origin.

Override the toString method to display the area and location of all of the shapes. That is, System.out.println(object) to display the data about the object.

Reference no: EM132198042

Questions Cloud

Find percentage change in real income of land owners : A country is endowed with 15 units of capital, 20 acres of land and 100 laborers. Capital and land are specific to the manufacturing and food sectors.
What would be an example in healthcare : What is the difference between a hypothesis and null hypothesis. What would be an example in healthcare?
Write the definition of a function with one parameter : Write the definition of a function dashedline, with one parameter, an int. If the parameter is negative or zero, the function does nothing.
Confidence interval estimate of the proportion of adults : Construct a 95% confidence interval estimate of the proportion of adults living in a household without landline phones. Show all work.
Determine if any of the circles overlap the triangle : Write an error-free Java program to do the following things. The program is modeled on a simple game where shapes move around the screen.
Weight change for each subject was recorded : Each of the 10 programs had 50 subjects in it. The subjects were followed for 12 months. Weight change for each subject was recorded.
Obtain the marshallian demand functions for goods : Obtain the Marshallian demand functions for goods X and Y. Compute the indirect utility function and the expenditure function for this case.
Display the left justified output on two seven segment : Display the left justified output on two seven segment displays, connected to the PORTC and PORTD of PIC 18.
Write an encryption and decryption program : Write an encryption and decryption program. Encrypt each digit by adding 7 and taking the remainder after division by 10.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Show the storage of matrix to minimize the access time

Repeat Problem, if the algorithm accesses both rows and columns of the matrix.n algorithm requires access to each row of an N x N matrix.

  How can quicksort be altered so that it can be applied

How can quicksort be altered so that it can be applied on a doubly-linked list?

  What combination of a and b will maximize contribution

What combination of A and B will maximize contribution, and what is the maximum possible contribution

  How to design a grade average program

plan a grade average program that will produce the numerical grade average of test scores input by a user.

  Why should people care about password security

Can computer hacking be justified under extraordinary circumstances. Imagine that you will have to break into a neighbor's car in order to drive a friend.

  Write a class called bar chart

Write a class called BarChart that compares the data using a bar graph representation. Allow the parameters to the constructor to specify the bar's width.

  What are advantage of compulsory initialization of variables

In some languages all variables must be initialized in their declarations. What are the advantages and disadvantages of compulsory initialization of variables?

  Derive an expression for the average access time ta

Given that, in a virtual memory system, if the probability of a page fault is p, the main-memory access time is tm and the time required to move a secondary.

  Abc institute of research has sensitive information that

abc institute of research has sensitive information that needs to be protected from its rivals. the institute has

  What problems did executives have with the eis

What problems did executives have with the EIS? What were the two reasons for those EIS problems?

  How do you think the tools will work in the future

How do you think these tools will work in the future? How will they impact major societal concerns like education, jobs, or the economy?

  Write a public static method named static long tribonacci

Write a public static method named static long tribonacci that returns the nth "tribonacci number" when initialially called with tribonacci.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd