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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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