Click here to Skip to main content
15,916,600 members
Home / Discussions / Java
   

Java

 
AnswerRe: Pdf em java (PDF in Java) Pin
OriginalGriff21-Jan-22 2:00
mveOriginalGriff21-Jan-22 2:00 
GeneralRe: Pdf em java (PDF in Java) Pin
Daniel Carvalho 202224-Jan-22 5:53
Daniel Carvalho 202224-Jan-22 5:53 
QuestionRe: Pdf em java (PDF in Java) Pin
David Crow24-Jan-22 6:06
David Crow24-Jan-22 6:06 
AnswerRe: Pdf em java (PDF in Java) Pin
Daniel Carvalho 202225-Jan-22 4:19
Daniel Carvalho 202225-Jan-22 4:19 
AnswerRe: Pdf em java (PDF in Java) Pin
Richard Deeming25-Jan-22 5:10
mveRichard Deeming25-Jan-22 5:10 
GeneralRe: Pdf em java (PDF in Java) Pin
englebart12-Feb-22 14:40
professionalenglebart12-Feb-22 14:40 
QuestionGetting data from a web site using Jsoup Pin
David Crow20-Jan-22 4:59
David Crow20-Jan-22 4:59 
AnswerRe: Getting data from a web site using Jsoup Pin
englebart12-Feb-22 14:44
professionalenglebart12-Feb-22 14:44 
Questionjava program Pin
Ricca Marie Fantilanan11-Jan-22 2:21
Ricca Marie Fantilanan11-Jan-22 2:21 
AnswerRe: java program Pin
Richard MacCutchan11-Jan-22 2:40
mveRichard MacCutchan11-Jan-22 2:40 
AnswerRe: java program Pin
Member 1550241316-Jan-22 23:01
Member 1550241316-Jan-22 23:01 
GeneralRe: java program Pin
Pete O'Hanlon16-Jan-22 23:18
mvePete O'Hanlon16-Jan-22 23:18 
GeneralRe: java program Pin
Richard MacCutchan17-Jan-22 0:39
mveRichard MacCutchan17-Jan-22 0:39 
AnswerRe: java program Pin
Prashanth Rao 202118-Jan-22 23:18
Prashanth Rao 202118-Jan-22 23:18 
Questionhow do i properly connect my external style sheet link to my jsp page. Pin
jonathanIckovich25-Dec-21 19:42
jonathanIckovich25-Dec-21 19:42 
QuestionWhat is causing error in my merge sort java code? Pin
Vivek Halakatti3-Dec-21 5:20
Vivek Halakatti3-Dec-21 5:20 
AnswerRe: What is causing error in my merge sort java code? Pin
Richard MacCutchan3-Dec-21 6:09
mveRichard MacCutchan3-Dec-21 6:09 
QuestionWhat may be the error in this java ->merge sort code? Pin
Vivek Halakatti2-Dec-21 7:15
Vivek Halakatti2-Dec-21 7:15 
AnswerRe: What may be the error in this java ->merge sort code? Pin
Richard Deeming2-Dec-21 21:29
mveRichard Deeming2-Dec-21 21:29 
QuestionWhy am I getting an error concatenating a String in java 16? Pin
Toml61828-Nov-21 6:13
Toml61828-Nov-21 6:13 
AnswerRe: Why am I getting an error concatenating a String in java 16? Pin
Gerry Schmitz28-Nov-21 7:58
mveGerry Schmitz28-Nov-21 7:58 
QuestionRe: Why am I getting an error concatenating a String in java 16? Pin
Richard MacCutchan28-Nov-21 8:13
mveRichard MacCutchan28-Nov-21 8:13 
AnswerRe: Why am I getting an error concatenating a String in java 16? Pin
Toml61828-Nov-21 9:55
Toml61828-Nov-21 9:55 
Questionhelp with 2d cellular automata in JavaSwing Pin
Suave6519-Nov-21 9:10
Suave6519-Nov-21 9:10 
Can someone help with this task?

Reuse the included class CA in order to provide graphical interface: instead of printing X's and blanks on the screen, black and white cells are drawn on the canvas depending on the CA's state. Your SwingCA class should accept a single argument representing a Wolfram's rule (handle exceptions!) and generate 600 generations each of size 400. For example, if you run java SwingCA 30 the image you get should resemble:

https://media.cheggcdn.com/media/59e/59e3b9d6-7ede-413d-a953-78cbb74e925b/phpYbnEbr[^]

REUSE THIS CLASS:

-----------------------------------------

public class CA {
// Data Members
private boolean[] cell;
private int size;
private int rule;
private boolean[] ttable;

// Constructor
public CA(int size, int rule) {
this.rule = rule;
this.size = size;

// Initialize Truth Table
ttable = new boolean[8];
for (int i = 0; i < ttable.length; i++) {
ttable[i] = (rule & 0x1) == 1? true: false;
rule >>= 1;
}

// Create Cells
cell = new boolean[size];
// Set Middle Cell To 1
cell[size / 2] = true;
}

// Compute And Return Next State
public boolean[] getState() {
// Array To Hold New State
boolean[] newCell = new boolean[size];

for (int i = 1; i < size - 1; i++) {
// Get Left Current And Right Values
int left = cell[i - 1]? 1 : 0;
int cur = cell[i] ? 1 : 0;
int right = cell[i + 1]? 1 : 0;

// Convert It To Decimal And Use It As Index For Rule Array
int ruleIdx = 4 * left + 2 * cur + 1 * right;

// Set New Cell Value To Rule TT Value
newCell[i] = ttable[ruleIdx];
}

// Update Cell Array
cell = newCell;

// Return New State
return cell;
}
}
QuestionRe: help with 2d cellular automata in JavaSwing Pin
Richard MacCutchan19-Nov-21 21:55
mveRichard MacCutchan19-Nov-21 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.