473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

what package to import when there is board?

50
hi all,
i'm trying out some examples on java..and i found this code where there is board and i cant find out what package to import to make this work, im getting error where there is "board"..
i have tried out the following but none worked:
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.applet.Applet;

plz help


Expand|Select|Wrap|Line Numbers
  1. import java.util.concurrent.CyclicBarrier;
  2.  
  3. public class CellularAutomata {
  4. private final Board mainBoard;
  5. private final CyclicBarrier barrier;
  6. private final Worker[] workers;
  7.  
  8. public CellularAutomata(Board board) {
  9.     this.mainBoard = board;
  10.  
  11.     int count = Runtime.getRuntime().availableProcessors();
  12.  
  13.     this.barrier = new CyclicBarrier(count, new Runnable() 
  14.     { // barrier action
  15.         public void run(){mainBoard.commitNewValues();
  16.         }
  17.         }
  18.     );
  19.     this.workers = new Worker[count];
  20.  
  21.     for (int i = 0; i < count; i++)
  22.         workers[i] = new Worker(mainBoard.getSubBoard(count, i));
  23.     } // constructor
  24.  
  25.     public void start() {
  26.         for (int i = 0; i < workers.length; i++)     
  27.             new Thread(workers[i]).start();
  28.         mainBoard.waitForConvergence();
  29. } // start()
  30. } // CellularAutomata
  31.  
  32.  
  33. class Worker implements Runnable {
  34.  
  35.     private final Board board;
  36.  
  37.     public Worker(Board board) { 
  38.         this.board = board; 
  39.         }
  40.  
  41.     public void run() {
  42.         while (!board.hasConverged()) {
  43.             for (int x = 0; x < board.getMaxX(); x++)
  44.                 for (int y = 0; y < board.getMaxY(); y++)
  45.                     board.setNewValue(x, y, computeValue(x, y));
  46.             try { barrier.await(); 
  47.             }
  48.             catch (InterruptedException ex) { return; }
  49.             catch (BrokenBarrierException ex) { return; }
  50.         } // while
  51.     } // run()
  52.  
  53.     private int computeValue(int x, int y) {
  54. // Compute the new value that goes in (x,y)
  55.  
  56. }
  57. } // Worker
  58.  
Jan 20 '09 #1
1 2030
JosAH
11,448 Expert 8TB
Board is certainly not a class that comes with your JSE distribution. I suggest you'd read that example again, maybe it's one of their classes and they have shown the source of that class.

kind regards,

Jos
Jan 20 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
2
by: Skip Montanaro | last post by:
At work we have a package structure for our homegrown code. Developers each have their own sandboxes where they work on the stuff they are responsible for (mixtures of C++ libraries, SWIG wrappers...
0
by: C. Barnes | last post by:
OK, here's the setup: package/ __init__.py X.py python/lib/ X.py Now inside package, we want to import the copy
4
by: flupke | last post by:
Hi, I developed a package with a structure like this src/ tesfile.py dir1/ __init__.py file1.py dir2/ __init__.py
2
by: kkrizl | last post by:
I have an Access database that has a few huge tables. It was taking about 20 minutes per table to import them from another application. I used the upsize wizard to put them in a SQL server...
4
by: Kunle Odutola | last post by:
I'm trying to understand where the information in the META.INF directory including MANIFEST.MF etc is to be found for .NET assemblies. Also some projects such as Eclipse's OSGi kernel stores...
11
by: fortepianissimo | last post by:
Say I have the following package organization in a system I'm developing: A |----B |----C |----D I have a module, say 'foo', that both package D and B require. What is the best practice in...
4
by: Martin Blais | last post by:
Hi I'm a tad confused over a problem involving cycles between packages. Assume the following sets of files:: driver.py a/__init__.py a/alice.py
0
by: Roger Ineichen | last post by:
Hi Tim For a usecase like this, I personaly recommend to defina all interfaces in one module which probably is a namespace if you need alot of interfaces to define. e.g. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.