Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Prompt
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rizzix




PostPosted: Sun Sep 14, 2003 11:41 am   Post subject: (No subject)

what packages do you need to import? That code does not look like any familiar code to me.

based on the following i presumed it was javascript.

you variables are not declared but directly defined.
screen.write(""); is something i'm sure java does not have.

anyways.. you might be using what is known as bsh or the bean shell.
i don't know much of the bean shell syntax. but it's supposed to be the Java scripting language. Technically any valid java code is a valid beanshell code. but not the other way round.


but if it is java that code won't compile. (as i said what packages do i need to import?)
Sponsor
Sponsor
Sponsor
sponsor
w0lv3rin3




PostPosted: Sun Sep 14, 2003 2:16 pm   Post subject: (No subject)

here is full code from a program I was pratcing on:

packages needed are avi.*

code:

import avi.*;


code:

//this is line comment for the human eye
//the compiler completely ignores comments
/*this is a block comment and allows you
 * to put block comments. Use this style
 * when you need more than a line comment
 */
//import java.lang.*;
import avi.*;
public class Hello //class name
{ //the beginning of the class definition
    public static void main(String[] args)
    { 
        Window screen = new Window("Testing","bold+italics","red",30);
        DialogBox inNumber1, inNumber2;
        //can do it in a seperate statement
        inNumber1 = new DialogBox(screen,"Input first integer");
        inNumber2 = new DialogBox(screen, "Input second integer");
       
        int number1, number2, sum, difference, product, remainder;
        float quotient;
        float fnum1 = 3.1f;
        double dnum1 = 3.3;
        short snum1 = 2;
        long lnum1 = 3;
        char cnum1 = 'q';
        boolean ans = false;
       
        int example1 = 3/2;
        float example2 = 3/2;
        //how to do the right arithmetic
        float example3 = 3.0f/2;
        //alternative way
        float example4 = (float)3/2;
        float example5 = (float)3 / 2 + 4 * 6;
        double example6 = 3.0/2;
        final float PI = 3.14f;
        //these two statements can replace the above statement
        //final float PI;
        //PI = 3.14f;
        //the next statement will give compilation error
        //PI = 2.3f;
        dnum1 = fnum1;//this is allowed
        fnum1 = (float)dnum1;//this is not allowed, want to do it
        number1 = 10;
        number2 = 5;
        screen.showWindow();
        //we will now use DialogBox class to take input
        //instead of hard coded data
        inNumber1.showDialogBox();
        number1 = inNumber1.getInteger();
        inNumber2.showDialogBox();
        number2 = inNumber2.getInteger();
       
        sum = number1 + number2;
        difference = number1 - number2;
        product = number1 * number2;
        quotient = (float)number1 / number2;
        remainder = number1 % number2;
       
        screen.write("Number1 = " + number1 + " and Number2 = " + number2);
        screen.write("\nSum = "+ sum);
        screen.write("\nDifference = "+ difference);
        screen.write("\nProduct = "+ product);
        screen.write("\nQuotient = "+ quotient);
        screen.write("\nRemainder = "+ remainder);
        screen.write("\n=========================================");
        screen.write("\nSum\tDifference\tProduct\tQuotient\tRemainder");
        screen.write("\n"+ sum + "\t\t" + difference + "\t\t\t\t" + product + "\t\t\t" + quotient + "\t\t" + remainder);
        screen.write("\n=========================================\n");
        screen.write("Example1 = " + example1);
        screen.write("\nExample2 = " + example2);
        screen.write("\nExample3 = " + example3);
        screen.write("\nExample4 = " + example4);
        screen.write("\nExample5= " + example5);
        screen.write("\nExample6= " + example6);
        screen.write("\nDouble = " + dnum1);
        screen.write("\nFloat = " + fnum1);
       
        screen.write("\nHello to all of you");
       // System.out.println("Hello to all of you");
    }
}
rizzix




PostPosted: Sun Sep 14, 2003 9:20 pm   Post subject: (No subject)

o ok.. ur using non-standard packages.. ur ehm.. college provides.
thats cool. although you can learn java with the standard packages.
nate




PostPosted: Mon Sep 15, 2003 9:48 pm   Post subject: (No subject)

for a college student you sure don't know your grammar.
Quote:

ur a biggest newb
Tony




PostPosted: Mon Sep 15, 2003 9:59 pm   Post subject: (No subject)

yeah... there should be a rule that when you post java code that implements non standart packages, please include all the "include..." lines so the rest of us wouldn't have to guess Wink

maybe rizzix should write it up, he knows Java better then I do
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rizzix




PostPosted: Wed Sep 17, 2003 4:27 pm   Post subject: (No subject)

yea i'd agree tony. there are far too many java-like scripting variants that look similar to java. it get's pretty confusing at times. I mean java code is 100% bean shell compatible yet not the other way round (i.e bsh code is not 100% java compatible). speaking of which do check out this awsome scripting language @ www.beanshell.org .. and don't be to hard on that dude, he probably got offended for some reason Confused
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 21 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: