Prepare a simple gui called boidgui

Assignment Help JAVA Programming
Reference no: EM131008768

Questions:

1. The class Boid represents a single movable object that can be drawn and run as a thread. The boid can move around the bounds of a panel with specified velocities in each of its x and y directions. Each Boid needs to know the position and velocities of the nearby (neighbouring) boids around it. However the class is not thread safe. Make the necessary changes to make this class thread safe and avoid any concurrency problems.

2. Using the following UML class diagram create a data structure calledBoidFlock that holds Boid objects in a list. The default constructor just creates an empty flock and initializes the boidList using an appropriate data structure, where the 2nd constructor creates a flock with the specified number of boids to start with. The addBoidToFlock method should add a new Boid to the boidList using random positions (0 - panel width and height) and velocities ( Boid.MAXSPEED), it also needs to pass itself as a reference to the newly created Boid, then should start the object up as a thread. The removeBoidFromFlock should remove an arbitrary Boid object from the list, also stopping its thread execution, destroyAllBoids should stop all boid threads running and clear the list, getNumberOfBoids returns the current number of boids in the list. The getNeighbours is used to return a new list of all the neighbouring boids that the boidToTest object has (excluding itself). A boid is a neighbour if its x and y value is within the DETECT RADIUS of the boidToTest parameter. Make sure this class uses generics where appropriate and that it is thread safe.

BoidFlock

+DETECTRADIUS : int

-boidList : List<Boid>

+BoidFlock()

+BoidFlock(numBoidsToStart:int)

+addBoidToFlock() : void

+removeBoidFromFlock() : void

+drawAllBoids(g:Graphics): void

+getNumberOfBoids() : int

+destroyAllBoids() : void

+getNeighbours(boidToTest:Boid) : List<Boid>

A boid with co-ordinates (x0, y0) is a neighbour to another boid (x1, y1) if: (x0 -x1)2 + (y0 -y1)2 <DETECTRADIUS2

3. Prepare a simple GUI called BoidGui to test the BoidFlock and Boid class which should display an entire flock of boids that move around within a panel bouncing off the walls. The GUI should repeatedly update its display by drawing the boids at fixed time intervals.. Add buttons for adding and removing boids or clearing the screen. Add sliders for manipulating radius detection and separation, cohesion and alignment weights of the boids.

4. Suppose an interface called RandomObtainable has been written for collections from which a random element should be obtainable. It has a method getRandom which should return an element randomly selected from the collection, and a method removeRandom that should try to remove a random element from the collection and insertRandom which inserts the element into the collection at a random location between zero and the size of the collection (inclusive). The getRandom should throw a NoSuchElementException if the collection is empty.

RandomObtainable

 

+getRandom() : E

+removeRandom() : boolean

+insertRandom(E element) : boolean

Extend the ArrayList class so that it implements this interface, and test it with a driver main method. At the top of your class in the header comments state what the asymptotic complexity is for each of the methods and why? If instead your class extended LinkedList, what are the asymptotic complexities?

Attachment:- java.zip

Reference no: EM131008768

Questions Cloud

What is first reaction to james easton opening statement : What is your first reaction to James Easton's opening statement, regarding who is responsible for the 9/11 attacks? Do you feel he provided enough evidence to prove his theory
Find dimensions for package that minimize production cost : The top will be made of glued paper, costing 0.08 cents per square centimeter. Find the dimensions for the package that will minimize production cost.
Definition of minority group : Write a 1.5 to 2 page (double spaced) paper that thoroughly follows all the criteria below: Identify and define the first of the two concepts you will be applying
Find dimensions for can that will minimize production cost : The material for the top and bottom of the can need to be thicker, and costs 0.05 cents per square centimeter. Find the dimensions for the can that will minimize production cost.
Prepare a simple gui called boidgui : Prepare a simple GUI called BoidGui to test the BoidFlock and Boid class which should display an entire flock of boids that move around within a panel bouncing off the walls.
What is the range of ages for people in the dataset : Aplumber has found that his service call times follow a normal distribution with a mean of 45 minutes and a standard deviation of 15 minutes. A random sample of five service calls was taken. What is the probability that the sample mean service tim..
How does corporate globalization contribute to immigration : How does corporate globalization contribute to immigration from Latin America to the United States
Find a formula for the volume of the box in terms of x : Find a formula for the volume of the box in terms of x. Find the value for x that will maximize the volume of the box.
What is the overall message of the group of articles : A statement of the conclusions that can be drawn when the articles are taken together as a single entity. What is the overall message of the group of articles? Focus specifically on how leadership behavior influences leadership results

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write the flow of execution of application

Write the flow of execution of application step by step and briefly explain the functionality of each function being called (like the first step would be to instantiate Frame and then instantiate Panel and place it into the Frame).

  Creates an object of type fahrenheit

Creates an object of type Fahrenheit and an object of type Celsius - Accepts a single argument from the command line

  Converting pseudocode to javascript

I would need help in converting converting pseudocode to JavaScript. I already have the pseudocode in a html file but need it to be converted to JavaScript and run like it should.

  Write program using a switch statement that display polygon

Write a program using a switch statement that displays the name of a polygon with sides between 3 and 12 depending on the number entered by the user

  If you are using the blackboard mobile learn app please

if you are using the blackboard mobile learn app please click view in browser. technical project address bookthis

  Create your listarray class

Create your ListArray class that is functionally similar to the formal Java ArrayList Utility class. here are the requirements

  What is printed out by the following code

What is printed out by the following code

  Define the determinant of a matrix

Define the determinant of a matrix a (written det(a)) recursively as follows: if a is a 1 x 1 matrix, then det(a) = x

  Design a course registration system

Create an application which represents a simplified course registration system using ArrayLists and HashMaps.

  Advantages and disadvantages of inline functions

advantages and disadvantages of inline functions

  Write java dice program

write java dice program.

  Write a java program to perform matrix multiplication

In this project you need to write a java program called to perform matrix multiplication and

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