Click to visit our sponsors!

homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam

  The Geek Culture Forums
  Your News!
  My Java Programming Class - 5 day course

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   My Java Programming Class - 5 day course
Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted July 29, 2002 10:13     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
Yay! I'm in my Java Prog. class right now, everyone! It's a happy, fun classL ... and I'm quite good at it, even though what we've done isn't much (and it's only about the 1st day taking the class). I won't be able to type much, seeing as I don't have *too* much free time. But I'll try... not that any of you care ! (Hehe, just kiddin') Anywho, here's what I've been doing:

code:
public class UseAccount {

public static void main(String[] args) {

Account myAccount;
Account yourAccount;


myAccount = new Account();
yourAccount = new Account();


myAccount.name = "Wendy Blevins";
myAccount.address = " - - - - - -";
myAccount.balance = 834.27;


yourAccount.name = "Dennis Bennett";
yourAccount.address = "42 Oak Street";
yourAccount.balance = 55.63;


myAccount.display();
System.out.println();
yourAccount.display();

}

}



code:
// HelloWorld.java: Your first Java Program

/**
* This first program will simple print
* "Hello World!" to the screen.
*/


class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello World!") ;

}

}


My two 'teachers' explained some 'terms' inside the code I didn't know, i.e. args, and public void display.

Yeh yeh, it's not much, but it's the most *I've* ever known, hah...

See ya'll around... hopefully... oh beh.

------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

maxomai
Super Geek

Posts: 194
From: Portland, OR
Registered: May 2001

posted July 29, 2002 11:57     Click Here to See the Profile for maxomai   Click Here to Email maxomai     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by Twinkle Toes:
Yay! I'm in my Java Prog. class right now, everyone! It's a happy, fun classL ... and I'm quite good at it, even though what we've done isn't much (and it's only about the 1st day taking the class). I won't be able to type much, seeing as I don't have *too* much free time. But I'll try... not that any of you care ! (Hehe, just kiddin') Anywho, here's what I've been doing:

code:
public class UseAccount {

public static void main(String[] args) {

Account myAccount;
Account yourAccount;


myAccount = new Account();
yourAccount = new Account();


myAccount.name = "Wendy Blevins";
myAccount.address = " - - - - - -";
myAccount.balance = 834.27;


yourAccount.name = "Dennis Bennett";
yourAccount.address = "42 Oak Street";
yourAccount.balance = 55.63;


myAccount.display();
System.out.println();
yourAccount.display();

}

}



code:
// HelloWorld.java: Your first Java Program

/**
* This first program will simple print
* "Hello World!" to the screen.
*/


class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello World!") ;

}

}


My two 'teachers' explained some 'terms' inside the code I didn't know, i.e. args, and public void display.

Yeh yeh, it's not much, but it's the most *I've* ever known, hah...

See ya'll around... hopefully... oh beh.


You forgot the "import" statements. Those are important .

Hope you find this fun.

IP: Logged

GameMaster
Highlie

Posts: 592
From: State of insanity
Registered: Mar 2002

posted July 29, 2002 12:57     Click Here to See the Profile for GameMaster   Click Here to Email GameMaster     Edit/Delete Message   Reply w/Quote
Heh, import is only important if you want it to compile...

It's great to see that your starting to program in a real language this early. Just wait untill you get into runtime polymorphisim (inheritance) and some windowing stuff... What book are they useing? *curosity*

IP: Logged

neotatsu
Highlie

Posts: 658
From: A place my soul no longer resides
Registered: Jun 2002

posted July 29, 2002 17:19     Click Here to See the Profile for neotatsu   Click Here to Email neotatsu     Edit/Delete Message   Reply w/Quote
Haha, good to see they still teach the 'hello world' thing first, that means my first day in my computer class next quarter will be a sinch

IP: Logged

ilovemydualg4
Highlie

Posts: 551
From: *GASP* THE 3RD DIMMENSION
Registered: Mar 2002

posted July 30, 2002 03:35     Click Here to See the Profile for ilovemydualg4   Click Here to Email ilovemydualg4     Edit/Delete Message   Reply w/Quote
very nice, going into 9th here, only offer is a class that includes html instruction. i know the guy though, and i highly doubt he would make me do something for him. if so, i could just pop one of my sites on a zip disk and bring em in

one more thing... ‘Oh beh’
never heard that one

------------------
my geek code
“Water outside boat good. Water inside boat bad. Water in air bad” - “Tim”

IP: Logged

Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted July 30, 2002 08:40     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
<<< I hate these computers... AHK, 'takes too long to load :-/ >>>

Oki... me second day: right now we're calculating interest rates. I had to add this:

code:

System.out.print("The interest on");
System.out.print(myAccount.name);
System.out.print("'s account is $");
System.out.println(myAccount.getInterest(5.00));
System.out.println();

double yourInterestRate = 7.00;
double yourInterestAmount;
System.out.print("The interest on");
System.out.print(yourAccount.name);
System.out.print("'s account is $");
yourInterestAmount = yourAccount.getInterest(yourInterestRate);
System.out.println(yourInterestAmount);
System.out.println();


Exciting, isn't it!? Eh, it's quite easy... quite. It's almost getting on me nerves that I haven't made a mistake,.. heh. We also went over the 'getInterest' method's header. But the most... 'exciting' and involved part was when we had to modify the program on our own. First, we were made to change the Account class so it contained the interest rate as one of its properties (- make a label, no biggie). Then, we had to change the display method in the Account class to include the interest rate and the interest amount. The last step was to add the lines back to the UseAccount class to set the interest and call the display method of both the myAccount instance and the yourAccount instance. This is how it turned out:

code:

public class UseAccount {

public static void main(String[] args) {

Account myAccount;
Account yourAccount;


myAccount = new Account();
yourAccount = new Account();


myAccount.name = "Wendy Blevins";
myAccount.address = "10295 Beep-Beep St.";
myAccount.balance = 834.27;
myAccount.interestRate = 5.0;


yourAccount.name = "Dennis Bennett";
yourAccount.address = "42 Oak Street";
yourAccount.balance = 55.63;
yourAccount.interestRate = 7.0;

myAccount.display();
yourAccount.display();


/*
System.out.print("The interest on");
System.out.print(myAccount.name);
System.out.print("'s account is $");
System.out.println(myAccount.getInterest(5.00));
System.out.println();

double yourInterestRate = 7.00;
double yourInterestAmount;
System.out.print("The interest on");
System.out.print(yourAccount.name);
System.out.print("'s account is $");
yourInterestAmount = yourAccount.getInterest(yourInterestRate);
System.out.println(yourInterestAmount);
System.out.println();
*/

}

}


I was the first person to actually grasped what the directions meant and finished before everyone else . I'm so proud of meself! Yay... !

------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

neotatsu
Highlie

Posts: 658
From: A place my soul no longer resides
Registered: Jun 2002

posted July 31, 2002 00:09     Click Here to See the Profile for neotatsu   Click Here to Email neotatsu     Edit/Delete Message   Reply w/Quote
alright, I'm posting this here because I figure since you have limited time online you'll come here first, so, Twinkie, pay attention now, I don't know what kind of security they have there, or whether you can get outside and walk around at night, but if you can or have the opportunity I'm begging you not to, and hoping I wasn't having one of my 'true dreams' at least, not about TONIGHT...anyway, the point is don't go out walking while your there PLZ! I doubt it's anything that'll happen, but I was just sitting here posting and I zoned out and had what I generally refer to as a 'quasi-dream' because I'm not really asleep but my concious thought isn't really awake either, anywho, I 'dreamt' of you walking down the street there, searching for a nice dark place where you can see the stars, and, well you were raped... that was the single most frightening dream I've ever had... you were raped and you went back to your dorm room and called the police, then called me, and I actually convinced my parents to let me take the car to go see you.. I want to see you really bad, but deffinately never under those curcumstances... like I said, it's more than likely nothing, but it's rather freaky considering it's somthing I've never really thought about untill after the little dream thingie, and call me paranoid, but better safe than sorry... okies, that's all...

IP: Logged

maxomai
Super Geek

Posts: 194
From: Portland, OR
Registered: May 2001

posted July 31, 2002 09:29     Click Here to See the Profile for maxomai   Click Here to Email maxomai     Edit/Delete Message   Reply w/Quote
Just wait until you start playing with AWT or Swing. You'll delight at the pretty GUI .. and stare in horror at how god awful slow it is.

After camp you should check out Python. The equivalent of your code in Python would be:

code:

# note: pseudocode, not tested


# this imports the account class with two methods: newAccount and
# display.
import TwinkleToesAccounts


# This method uses the account class.
def UseAccount:


# create accounts
myAccount = account.newAccount()
yourAccount = account.newAccount()

# initialize myAccount
myAccount.name = "Wendy Blevins"
myAccount.address = "123 Blah St."
myAccount.balance = 834.27


# initialize yourAccount
yourAccount.name = "Dennis Bennett"
yourAccount.address = "42 Oak St."
yourAccount.balance = 55.83


# display accounts
myAccount.display()
print '\n'
yourAccount.display()


# executes UseAccount
UseAccount


Notice a few differences. First: not a lot of syntactical markers. That's because Python uses white space to indicate structures, rather than semicolons and braces.

Second: no need to define a separate class just to handle this function.

Hope this helps

IP: Logged

Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted July 31, 2002 09:50     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
<<< Aye!! It is quiggy-super FUN, maxomai! >>>

Alrig', well today we created an Address Book:

code:
public class UseAddress {

public static void main(String[] args) {


Address myAddress;
Address yourAddress;

myAddress = new Address();
yourAddress = new Address();

myAddress.name = "Wendy Blevins";
myAddress.address = "10115 Holly Drive";
myAddress.email = "[email protected]";
myAddress.phonenumber = "355 6986";


yourAddress.name = "Jessica Cermak";
yourAddress.address = "123 Fake Street";
yourAddress.email = "[email protected]";
yourAddress.phonenumber = "355 6778";

yourAddress.name = "Cassandra Dietman";
yourAddress.address = "463 Monkey Socks Avenue";
yourAddress.email = "[email protected]";
yourAddress.phonenumber = "475 9657";

yourAddress.name = "Scott McKee";
yourAddress.address = "345 Blah-Blah Land";
yourAddress.email = "[email protected]";
yourAddress.phonenumber = "281 3567";

myAddress.display();
yourAddress.display();

}

}


Yay! Fun little addresses, heeh... *cough* anywho, then afterwards we had to write a 'longer' code (about 78 lines or so) called "Guess" in which we created a integer-guessing game.
code:
import java.io.*;

class Guess {

int min;
int max;

int theNumber;

String prompt = "> ";

BufferedReader in = new BufferedReader (new InputStreamReader(System.in));

public Guess(int low, int high) {
this.min = low;
this.max = high;

this.theNumber = getRandom(this.min, this.max);
}

public int getRandom(int minimum, int maximum) {

return (int) ((Math.random() * (maximum-minimum+1)) + (minimum));
}

public int getInt() {
int number = 0;
String temp;
boolean gotNumber = false;
while(!gotNumber) {
System.out.print(prompt);
try {
temp = in.readLine ();
number = Integer.parseInt (temp);
gotNumber = true;
}

catch(NumberFormatException e) {
gotNumber = false;
System.out.println("That didn't look like an integer number, try again.");
}

catch(IOException e) {
System.out.println("Error getting input: " + e. toString());
gotNumber = false;
}
}
return number;
}

public void start() {
String line = "";
boolean correct = false;
int guess;
System.out.println("I am thinking of a number between " + this.min + " and " + this.max + ".");
while(!correct) {
System.out.println("Enter your guess.");
guess = getInt();
if(guess < theNumber) {
System.out.println("Your guess is too low.");
}

if(guess > theNumber) {
System.out.println("Your guess is too high.");
}

if(guess == theNumber) {
System.out.println("Correct!");
correct = true;
}
}

}

public static void main(String[] args) {
int low = 0;
int high = 100;

Guess game = new Guess(low, high);

game.start();
}

}


I finished 2nd (the other geek beat me by a few seconds ), and only got one mistake ... semi-colon, hehe.

To me, this is better than me engineering class! And we're making robots in there, haha...

Oy! GM, sorry I forgot about your question: I asked one of me 'teachers' and he said he used 4 or 5 different books to teach us all this. He didn't remember what they were all called except two.

But *I* don't remember the exact title and author from memory , but I can find them in The Bookie (student book store) - I was thinking about buying one so I could continue learning more aboot Java...

------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted July 31, 2002 10:03     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
Oh, and thankfully for you, Bees... we're not at all allowed to go outside. If we do, we get sent back home, heh...

I love you... stop worrying so much!

------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

maxomai
Super Geek

Posts: 194
From: Portland, OR
Registered: May 2001

posted July 31, 2002 13:30     Click Here to See the Profile for maxomai   Click Here to Email maxomai     Edit/Delete Message   Reply w/Quote
This is some good code TT! Would you mind a few tips from an old-timer?

First thing is, coding isn't a race. The object is to do it right .. which means that the code runs correctly, is more or less foolproof, and is readable, at least in my book. Other coders will disagree with me here.

Second, you're indenting with tabs from the look of things. I would try indenting with either two or four spaces. I'm not sure what kind of editor you're using, but your instructor should be able to show you how to set your tab key to produce two or four spaces instead. This can make your code a lot more readable. (Research shows that four spaces is best; I use two because it suits my eyes better. Your mileage may vary.) I would also indent the stuff just inside the class (the fields and methods) by one level (two spaces). Otherwise your indentation looks great.

Third, you might want to get into the habit of adding comments. Commented code is a lot easier to understand for a human being than uncommented code. Some coders *start* by writing comments and *then* add code later; this helps them to think through complex problems. I added a comment for every function, a comment for every variable, and comments for blocks of code that might take more than a second to figure out.

Fourth, I noticed that you used three if statements: one for guess < number, one for guess > number, one for guess == number. I turned this into an if-then-else statement. This way you do one or two compares instead of three. This isn't a big deal for this code, but if this were the 10% of your code that runs 70% of the time, the efficiency increase could be substantial.

The results are below:

code:

//---------------------------------------------
// class Guess
//
// Plays a number guessing game with the user.
//---------------------------------------------

import java.io.*;

class Guess {

int min; // minimum guess so far; at least 0
int max; // maximum guess so far; at most 100
int theNumber; // the number that the user tries to guess!

String prompt = "> "; // string to prompt the user for a guess.

BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
// used to read user input


//------------------------------------------
// constructor
// public Guess (int, int)
//
// Sets variables for the start of the game.
//-------------------------------------------
public Guess(int low, int high) {
this.min = low;
this.max = high;
this.theNumber = getRandom(this.min, this.max);
}


//--------------------------------------------
// public int getRandom (int, int)
//
// returns a random integer between
// minimum and maximum
//--------------------------------------------
public int getRandom(int minimum, int maximum) {
return (int) ((Math.random() * (maximum-minimum+1)) + (minimum));
}


//-------------------------------------------
// public int getInt()
//
// Gets an integer guess from the user's input;
// does sanity checks.
//-------------------------------------------
public int getInt() {
int number = 0; // hold's the number that the user entered (we hope)
String temp; // holds the user's input.
boolean gotNumber = false; // will be set to TRUE when we have an int.

// repeat until we get a number.
while(!gotNumber) {
System.out.print(prompt);


// try to get a number
try {
temp = in.readLine ();
number = Integer.parseInt (temp);
gotNumber = true;


// doesn't seem to be a number; try again.
} catch(NumberFormatException e) {
gotNumber = false;
System.out.println("That didn't look like an integer number, try again.");


// got an IO error. Try again.
} catch(IOException e) {
System.out.println("Error getting input: " + e. toString());
gotNumber = false;
}
}

return number;
}


//---------------------------------
// public void start()
//
// Start the game and repeat until
// the number has been guessed.
//---------------------------------
public void start() {
String line = ""; // not sure what this does .. delete?
boolean correct = false; // becomes TRUE when the user guesses the number
int guess; // the user's guess

System.out.println("I am thinking of a number between " + this.min + " and " + this.max + ".");


// repeat until the number is guessed
while(!correct) {
System.out.println("Enter your guess.");
guess = getInt();


if(guess < theNumber) {
System.out.println("Your guess is too low.");
} else if(guess > theNumber) {
System.out.println("Your guess is too high.");
} else /* (guess == theNumber) */ {
System.out.println("Correct!");
correct = true;
}
}
}


//--------------------------------------------
// public static void main(String[])
//
// Initializes and plays the game when we
// execute this class.
//---------------------------------------------
public static void main(String[] args) {
int low = 0;
int high = 100;

Guess game = new Guess(low, high);

game.start();
}

}


The style that I use here is what works for me and for some teams that I've worked with. Please note that some geeks are going to disagree with the my coding style. In fact, I hope they do; there are many different styles out there, and our disagreements are your learning opportunities. The basic elements are still the same, however.

Hope this helps.

IP: Logged

nekomatic
Assimilated

Posts: 439
From: Manchester, UK
Registered: Mar 2000

posted August 01, 2002 02:43     Click Here to See the Profile for nekomatic   Click Here to Email nekomatic     Edit/Delete Message   Reply w/Quote

IP: Logged

maxomai
Super Geek

Posts: 194
From: Portland, OR
Registered: May 2001

posted August 01, 2002 09:12     Click Here to See the Profile for maxomai   Click Here to Email maxomai     Edit/Delete Message   Reply w/Quote
Interesting Nekomatic, I'm not familiar with this tool. What is it?

IP: Logged

Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted August 01, 2002 09:28     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
Yay!! We had to modify "Guess". Heeehee, I jumbled the responses around a tad,.. KEEH! I'm a silly-poo!
code:

import java.io.*;

class Guess {

int min;
int max;

int theNumber;

String prompt = "> ";

BufferedReader in = new BufferedReader (new InputStreamReader(System.in));

public Guess(int low, int high) {
this.min = low;
this.max = high;

this.theNumber = getRandom(this.min, this.max);
}

public int getRandom(int minimum, int maximum) {

return (int) ((Math.random() * (maximum-minimum+1)) + (minimum));
}

public int getInt() {
int number = 0;
String temp;
boolean gotNumber = false;
while(!gotNumber) {
System.out.print(prompt);
try {
temp = in.readLine ();
number = Integer.parseInt (temp);
gotNumber = true;
}

catch(NumberFormatException e) {
gotNumber = false;
System.out.println("That didn't look like an integer number, you're either drunk, a crackhead, or have really messed up fingers. Try again.");
}

catch(IOException e) {
System.out.println("Error getting input: " + e. toString());
gotNumber = false;
}
}
return number;
}

public void start() {
String line = "";
boolean correct = false;
int guess;
int numberofguesses = 0;
System.out.println("I am thinking of a number between " + this.min + " and " + this.max + ".");
while(!correct) {
System.out.println("Enter your guess, NOW! Now, you incompitent monkey!");
guess = getInt();
if(guess < theNumber) {
numberofguesses++;
tries = tries + 1;
System.out.println("Your guess is obviousely too low. No one will ever believe your theory on how you created the rubber ball.");
}

if(guess > theNumber) {
numberofguesses++;
tries = tries + 1;
System.out.println("Your guess is too high. So are you.");
}

if(guess == theNumber) {
numberofguesses++;
tries = tries + 1;
System.out.println("OOH, you got it right. After all those tries, ya big ape.");
correct = true;
System.out.println("It took you " + numberofguesses + " guesses. You must have an IQ of 14, ya pansy!");
}
}

}

public static void main(String[] args) {
int low = 0;
int high = 100;

Guess game = new Guess(low, high);

game.start();
}

}


And THEN, I wrote 85 lines which created a quiggy little calculator . I'm trying to add a subtraction, multiplication, and maybe division section rig' now...

code:

import java.io.*;

public class Calculator {


BufferedReader in;
String prompt = "> ";

public Calculator() {

in = new BufferedReader(new InputStreamReader(System.in));
}

public void displayMenu() {

System.out.println("\n\n");
System.out.println("Select a number: ");
System.out.println("-----------------");
System.out.println("1 Addition");
System.out.println("\n9 - Quit");
System.out.println("-----------------");

}

public String getStringInput() throws IOException {

System.out.print(prompt);
String temp = "";
try {

temp = in.readLine();
}

catch(IOException e) {

System.out.println("Error getting input: " + e.toString());
}

return temp;
}

public int getIntInput() {

int number = 0;
String temp;
boolean gotNumber = false;
while(!gotNumber) {

System.out.print(prompt);

try {

temp = in.readLine();
number = Integer.parseInt(temp);
gotNumber = true;

}

catch(NumberFormatException e) {
gotNumber = false;
System.out.println("That didn't look like an integer number, try again.");

}

catch(IOException e) {
System.out.println("Error getting input: " + e.toString());

}
}

return number;
}

public void doAddition() {

int n1, n2;
System.out.println("\n");
System.out.println("Enter the first number: ");
n1 = getIntInput();
System.out.println("Enter the second number: ");
n2 = getIntInput();
System.out.println("Results: " + n1 + " + " + n2 + " = " + (n1 + n2));

}

public static void main (String[] args) throws IOException {

String menuSelection = "";
Calculator calc = new Calculator();
boolean running = true;

while(running) {

calc.displayMenu();
menuSelection = calc.getStringInput();
if(menuSelection.equals("1")) {

calc.doAddition();
}

else if(menuSelection.equals("9")) {
running = false;
}

else {

System.out.println("That doesn't look like anything on the menu, try again.");

}

}

}

}


------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

Twinkle Toes
Highlie

Posts: 666
From: a place that no longer holds my soul...
Registered: Mar 2002

posted August 01, 2002 09:31     Click Here to See the Profile for Twinkle Toes   Click Here to Email Twinkle Toes     Edit/Delete Message   Reply w/Quote
Oops... sorry. I don't like it when ya have ta scroll... over... like so.

But look what I made!

()()
(0.0)
(')(')o HEY! ME 666TH POST!! LOOK AT THAT, BEES!

------------------
"If it's made with Schmucker's Brand Rasberry Preserves, you know it's good."

IP: Logged

neotatsu
Highlie

Posts: 658
From: A place my soul no longer resides
Registered: Jun 2002

posted August 01, 2002 12:28     Click Here to See the Profile for neotatsu   Click Here to Email neotatsu     Edit/Delete Message   Reply w/Quote
yeah, I had noticed that too Twinkie

IP: Logged

GameMaster
Highlie

Posts: 592
From: State of insanity
Registered: Mar 2002

posted August 01, 2002 20:58     Click Here to See the Profile for GameMaster   Click Here to Email GameMaster     Edit/Delete Message   Reply w/Quote
I prefer the deep tabs, and absolutly hate Emacs auto-formatting... I am nit picky about the opening and closing braces being lined up with the code before (the signature for the function or class, and the conditions for if, fors, whiles...). if it happens to require me to wrap a line (instead of scrolling) so be it. I'll find a logical break and add an extra tab.
code:

...
while(x)
{
if(y)
{
}
}

public func(int a, int b, //if it were too long
inc c)
{
}
...


IP: Logged

nekomatic
Assimilated

Posts: 439
From: Manchester, UK
Registered: Mar 2000

posted August 02, 2002 01:00     Click Here to See the Profile for nekomatic   Click Here to Email nekomatic     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by maxomai:
Interesting Nekomatic, I'm not familiar with this tool. What is it?


LabVIEW. It's a graphical programming language made by National Instruments and oriented towards test/measurement/control.

I started using it a couple of years ago when I had to get an automated test up and running and didn't fancy learning C or VB (or waiting for someone else to do the software for me) and it's very easy for a novice to get to grips with. It's very good for applications where the user interface is fairly constant and the data input and output requirements are fairly well known - such as test/measurement/control - but it wouldn't be the best tool for writing something like a word processor, though you probably could if you were bloody-minded enough. Two of its real strengths are that you rarely have to worry about memory management and that it automatically handles scheduling of parallel tasks - making your program do 'two things at once' is literally as easy as creating the two bits of code on the same diagram.

The development system (available on Windows, Mac, Linux, Sun, HPUX) is in the $1000-3000 range but there is a slightly limited 'student edition' for Windows and Mac available as a book/CD package for about $50-60. You're supposed to be a student, but Amazon don't check

Any further questions, please ask!

IP: Logged

maxomai
Super Geek

Posts: 194
From: Portland, OR
Registered: May 2001

posted August 02, 2002 13:47     Click Here to See the Profile for maxomai   Click Here to Email maxomai     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by GameMaster:
I prefer the deep tabs, and absolutly hate Emacs auto-formatting... I am nit picky about the opening and closing braces being lined up with the code before (the signature for the function or class, and the conditions for if, fors, whiles...). if it happens to require me to wrap a line (instead of scrolling) so be it. I'll find a logical break and add an extra tab.

I used to be nit-picky that way, then I realized that the point isn't to follow a standard as much as it is to make the code legible to a human being. There's also a java-specific convention of putting starting braces at the end of the line that has the function signature / conditional statement / caught exception / try statement / etc. I think this looks better in the long run; consider:

code:

if (this.groovy)
{
System.out.println("groovy");
}
else if (this.cool)
{
System.out.println("cool");
}
else
{
System.out.println("bogus");
}

vs.

code:

if (this.groovy) {
System.out.println("groovy");
} else if (this.cool) {
System.out.println("cool");
} else {
System.out.println("bogus");
}

Again, YMMV.

IP: Logged

All times are Pacific Time

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | Geek Culture Home Page

© 2002 Geek Culture® All Rights Reserved.

Powered by Infopop www.infopop.com © 2000
Ultimate Bulletin Board 5.47e

homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam