The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
Basically I'm trying to write a program to do my coursework for me.
It's to generate a huge truth table for some boolean logic or something. It wouldn't take *that* long to do by hand, but that's not the point. I take a Java class too so I thought it'd be good practice.
The basic idea is that I use a bunch of arrays to hold the information and then just pick in the format needed.
So I've written a method to populate the input variable (arrays) with 0s and 1s
[I plan to change it so it only has to be called once instead of one time per variable but I haven't thought about an alogrithm for that yet]
The relevent bits are:
private int[] s0,s1,i0,i1,i2,i3; //arrays for the input variables
public void populate(int n, int[] var) {
//n is number in an alternation.
//var is the input variable array to write into.
int total = (rows/n)/2;
for (int c = 0; c < total; c++) {
for (int i = 0; i < total; i++) {
for (int j = 0; j < n; j++) {
var[c] = 0;
}
for (int k = 0; k < n; k++) {
var[c] = 1;
}
}
}
}
Then I call this from main()...
TruthTable t1 = new TruthTable(64);
t1.populate(32, s0);
And it gives me some crap about static contexts:
[Mark@localhost Java Source]$ javac TruthTable.java
TruthTable.java:52: non-static variable s0 cannot be referenced from a static context
t1.populate(32, s0);
^
1 error
What am I doing wrong?
It killed my lovely neat indentation :(
And you'll have to excuse my hundereds of for loops, it wasn't really planned :p
----
Okay nevermind I got it :p
Basically I'm trying to write a program to do my coursework for me.
It's to generate a huge truth table for some boolean logic or something. It wouldn't take *that* long to do by hand, but that's not the point. I take a Java class too so I thought it'd be good practice.
The basic idea is that I use a bunch of arrays to hold the information and then just pick in the format needed.
So I've written a method to populate the input variable (arrays) with 0s and 1s
[I plan to change it so it only has to be called once instead of one time per variable but I haven't thought about an alogrithm for that yet]
The relevent bits are:
private int[] s0,s1,i0,i1,i2,i3; //arrays for the input variables
public void populate(int n, int[] var) {
//n is number in an alternation.
//var is the input variable array to write into.
int total = (rows/n)/2;
for (int c = 0; c < total; c++) {
for (int i = 0; i < total; i++) {
for (int j = 0; j < n; j++) {
var[c] = 0;
}
for (int k = 0; k < n; k++) {
var[c] = 1;
}
}
}
}
Then I call this from main()...
TruthTable t1 = new TruthTable(64);
t1.populate(32, s0);
And it gives me some crap about static contexts:
[Mark@localhost Java Source]$ javac TruthTable.java
TruthTable.java:52: non-static variable s0 cannot be referenced from a static context
t1.populate(32, s0);
^
1 error
What am I doing wrong?
It killed my lovely neat indentation :(
And you'll have to excuse my hundereds of for loops, it wasn't really planned :p
----
Okay nevermind I got it :p