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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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