macca cronin

Greenhorn
+ Follow
since Aug 05, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by macca cronin

Hi there,

I'm currently trying to write a program that requires me to generate some mathematical formulas. I've been able to use the extended ascii codes to represent some of them using code like below :
int i = 64;
String aChar = new Character((char)i).toString(); //Prints the ascii value of 64

Some operators are not supprted however. I was wondering whether anyone knows how to define the logical connective "and" and "or" symbols ('look like an 'upside-down' V and V respectively), as well as the symbols for universal and existensial quantification. Any help would be greatly appreciated
20 years ago
Hey there,

I'm new to java and I need to write a string that i generated in my code to an output file. I'm currently writing the string to the standard output like so :

System.out.println("K_"+Receiver+",t"+msgnum+"(R("
+Receiver+",t"+msgnum+"("+out1+")))");

All the types e.g. 'Receiver' or 'out1' are of type string. Could anyone show me how to open a file for writing and then write this information to the file? Is there some sort of file writer equivalent for system.out.println()? Thanks very much
20 years ago
Hi there,

First off I'm new to java and coding in general so please bear with me. I'm trying to write a bit of code that will convert something like the following
con(pk(B),pk(AS),pk(A),B)
to this
k_B, k_AS, k_A, B

I have written the following code :

Pattern pk = Pattern.compile("pk(.*)"); //Regular Expression Pattern

int varsLen = initialVars.length();
String[] elements = initialVars.split(","); //Split up the terms
for (int x=0; x<elements.length; x++) {
Matcher m = pk.matcher(elements[x]); //match array element
boolean b = m.matches();//Does array element match
if (b) {//If there is a match
pkStart = elements[x].indexOf("pk(", pkEnd) + "pk(".length();
pkEnd = elements[x].indexOf(")",pkStart);
elements[x] = elements[x].substring(pkStart,pkEnd);
csPrelimOut = "k_"+elements[x];
csOut = csOut.concat(csPrelimOut);
} else {
csPrelimOut = elements[x];
csOut = csOut.concat(csPrelimOut);
}

}
csOut = csOut.replace(' ',',');

When I use this code it always works for the first element of the array but not the remaining elements. I'd get k_B from pk(B), but for the remaining pk() elements i'd just get them reiterated e.g. pk(AS) would remain pk(AS). I've never used regular expressions before so maybe that's where I'm going wrong. From "Pattern pk = Pattern.compile("pk(.*)");", I mean to set up a regular expression that starts with "pk(", then can be followed by 1 or more characters, and finally ended with ")". Does anyone have any idea how I might sort this out? Thanks a million.
20 years ago
Hey,

I've just started using Microsoft Visual J++ and I have a problem regarding its use. It is regarding the jdk version that Visual J++ (version 6.0) uses. I want to use the String class methods split() among others that are part of the java.util.regex.* package but the version of Visual J++ I have does not recognise these packages. When I import just java.util.* I get the error "'split' is not a method of class String (J0235)", whereas whan I include the java.util.regex.* package I get the error "Undefined package java.util.regex (J0051)". When I was not using the Visual J++ environment and just javac from the commandline I got the same problem, until I updated my jdk from 1.3 to 1.4 so that's why I think the problem lies with the jdk that Visual J++ is using (however I really don't know my way around Visual J++ yet so I could be totally wrong!!). Could anyone let me know why I'm getting this problem and how I might solve it. Thanks very much.
Not sure if this is the correct forum to post this question. I've just downloaded the free jbuilder foundation application. I've used an earlier version of jbuilder(1.01) and when I create a new project, I simply add the files I need to the project, make the project and then I can run or debug it. With this new version however, I am able to successfully compile my project but when I want to run or debug it, the edit runtime configurations dialog box keeps popping up. I have the following settings:
Name: Configuration1
Build Target: Make
Type: Application

I have nothing specified in main class, VM paramaters or Application parameters. When I click ok on the edit runtime config dialog, a message pops up that says "Unable to start runtime due to incomplete configuration". I'm very new to programming and jbuilder so could anyone shed some light on this problem of mine. What extra config info do I need to put in? Thanks very much
Hey,

I'm not entirely sure how to use string tokenizers. i've got a string that is delimited with commas i.e.
StringTokenizer st1 = new StringTokenizer(a,",");

What i need to do now is store each of the tokens of the string so that I can use them later in my program. I'm trying something along the lines of
while (st1.hasMoreTokens()) {
String term = st1.nextToken();
System.out.println("Output: "+ term);
}
With this though, all I get is the tokens outputted. As i said I need to be able to call on them later so I need some way of storing them. Could anyone give me a clue to solving this problem as I'm kinda lost at the mo!

Thanks a million
20 years ago
Hey there,

First off I'm really new to Java so please bear with me. I need to translate a line of text from one form to another. An example line segment has the following format:

" step(sent(1,A,B,vars(Na,Rv,ped(pk(B),cat(Na,A)))))"

This means that at step 1, A sends to B that which is contained in vars() i.e. Na, Rv and encryption of Na and A (concatenated) using B's public key [ped(pk(B),cat(Na,A))]

The output format I need is the following:

"Knows_B,time_1(Received(B,time_1,(Na,Rv,enc({Na,A},pk_B))))"

Basically this is the same information that is in the input format but I just need to translate it to the output format above i.e. 'knows_B' corresponds to 'B'; 'time_1' corresponds to '1'; 'ped' corresponds to 'enc'; 'pk(B)' corresponds to 'pk_B' and 'cat(Na,A)' corresponds to '{Na,A}'. I've tried using string tokenizers to extract the data from the input and thus build the output form, but I just haven't been able to extract the data properly. If anyone has the time could they perhaps give me an example of some code that might solve this problem.

If anyone needs more information regarding the input format and how it's related to the output format I will try and elaborate some more on their connection.

Please help!
Thanks a million.
20 years ago