You are not logged in.
Well, I started my Computer Programming Java class and well im a total noob at it.
Any comments from the pros or intermediate people out there?

Offline
you should at least get 2 hours a day if you wana be a pro and i recomend you to start with c++ it is the easiest one

Offline
wakra wrote:
you should at least get 2 hours a day if you wana be a pro and i recomend you to start with c++ it is the easiest one
you must be crazy lol C++ is the hardest programming language out there. Krazy, if you want to start off with something simple. Look up Python or Visual Basic. That will give you a basic understanding of programming. It will actually help you on JAVA
Offline
Yeah, Last night was the first time we got in the Lab class where we started to write code. We wrote a basic HelloWorld app and then we had to make it more complex by adding another line of code to say hello 5 times with out adding a "system.out.println"
public class HelloWorld
{
public static void main(String [] args )
{ // List of Names.
sayHello ("Ben");
sayHello ("Ben2);
sayHello ("Ben3");
sayHello ("Ben4");
sayHello ("Ben5");
}
public static void sayHello (String name)
{ /*This is saying hello
then adding a name after to say Hello World ____ */
System.out.println ("Hello World " + name);
}
}
what confused me were the parts in bold.

Offline
it gets more complex afterwards. Especially when you get into IF THEN statements. I use SQL everyday on my job which is used for DB but its totally different. SQL is still coding but its nowhere near Programming
Offline
Yeah, I have seen the If,Else, or If Else statement examples...

Offline
Hmm... can't help you here, but Id like to learn code.
I also know Perl is easy to use. I know a very little bit of it.
Ruby is also supposed to be good.
I'd like to get a good book ![]()

Offline
Yeah I need to get a book on Java... but books are so damn expensive..

Offline
hook me up lol.

Offline
thank you my good sir.

Offline
Passed my AP class in java last year. Look up Big java by Cay Horstmann. I got a pretty good ebook i can probably give you too. I"ll upload it later today. I also know of a few good practice sites. And could recommend some good IDE. Personally i say you code with eclipse, but there are many choices. Post any questions cause i recently went through this all and probably could answer them all.

Offline
Im using Eclipse for my Java coding. Anything that can help will be great canUrollwithTHIS! Thanks.
also can you explain to me in the bold of my second post?

Offline
public static void main(String [] args ) or public static void sayHello (String name)
ok everytime you see something like this followed by opening and closing bracets ({ } <---these things) and stuff in between them, it's going to be something that we call a method. A method is kinda like a factory in real life. You put stuff in, and other stuff comes out. For example you put leather in a shoe factory and get shoes. So in teh case of sayHello, you input a "name", in the form of a string and it prints it out for you. Now the case of the "main" method is a little different. Every program in java will have that method, as you can see it takes in a "String[] args", well the system passes in the args for you so you don't have to worry about that. All you need to know is that the point of that method is basically to just start up the program you coded.

Offline
Alright well this was my 2nd day in the Lab class again i was kinda lost but need another persons explanation... on Loops/Logic and If/Else statements.
This is what I had to do in my class....
-----------------------------------------------------------------------------------------------------------------------------------
1. Write a method that prints all of the integers between 0 and some number N. Call the method from
main() with some value for N.
2. Imagine you need to open a combination lock. The lock has three dials, each with a range of 0 to 9. Write
a method that prints all of the possible combinations of the lock. Call the method from main().
3. Continue with your program from #2. Imagine the lock is not very reliable. It will open if the first dial is
within 1 of the correct combination, and the second dial is within 3, and the third dial is within 5. Modify
your method to only output combinations that will open the lock. The correct combination should be
passed in as parameters to the method. Call your method from main().
4. Write a program that prints the first 25 Fibonacci numbers. A Fibonacci number is the sum of the previous
two numbers in the sequence. For example, the first six Fibonacci numbers are (1,1,2,3,5,8,…).
-----------------------------------------------------------------------------------------------------------------------------------
The first one was easy.
The second one not so since I was kinda lost.
The third one I had a lot of trouble with.
The fourth one i didnt even touch since i have no clue what Fibonacci is.
---------------------------------------------------------------------------------------------------------------------------------------
Here are my source codes...
#1
public class Increment
{
public static void main(String [] args )
{
for (int i=0; i<=9; i++) // Integers of only 0 to 9
{
System.out.println(i); // Prints out 0 to 9
}
}
}
#2
public class Lock
{
public static void main (String [] args)
{
for (int x=0; x<=9; x++) // X is First Dial of numbers
{
for (int y=0; y<=9; y++) // Y is Second Dial of numbers
{
for (int z=0; z<=9; z++) // Z is Third Dial of numbers
{
System.out.println("x:"+x+ "y:"+y+ "z:"+z); // Prints out 3 digit numbers from 000 to 999
}
}
}
}
}
#3
public class Lock2
{
public static void main (String [] args)
{
crackLock(8,7,3);
}
public static void crackLock (int dail1,int dail2, int dial3)
{
for (int x=0; x<=9; x++) //First Set of Numbers
{
for (int y=0; y<=9; y++) // Second Set of Numbers
{
for (int z=0; z<=9; z++) // Third Set of Numbers
{
System.out.println("x:"+x+ "y:"+y+ "z:"+z);
}
}
}
}
}
-------------------------------------------------------------------------------------------------------------------------
If I can get some sort of explanation on whats going on in each code that'd be great.

Offline
the fourth one is pretty simple once you understand how it works
even though its in c++ you still should be able to copy the concept
#include <iostream>
using namespace std;
int fib(int num);
int main()
{
for(int i=1;i<=25;i++)
cout<<fib(i)<<", ";
cout<<endl;
return 0;
}
int fib(int num)
{
if(1==num||2==num)
return 1;
else
return fib(num-1)+fib(num-2);
}Last edited by Joe88 (2008-09-11 03:08:57)

Offline
well guys...im still going in this class and well its getting harder lol.
im doing arrays and 2d graphics right now.
im designing a Tic Tac Toe game in Java then I have to converter it to C++.
canUrollwithTHIS, any words of advice?

Offline
Making the tic tac toe game won't be too hard. It can be easily represented in a 2 dimensional array. The hardest part of that would be the GUI, if the assignment doesent require GUI, then just make it in a console, it'll look ghetto as hell lol, but it'll work.
p.s. Don't worry about converting it to c++ till the very end, it shouldent be that hard, you can reason it out by comparing syntaxes of the languages, but make sure to leave that till the end.

Offline
well, one of my buddies who is in his 3rd year of computer science/enginering helped with this console version of tic tac toe multidimensional arrays. I will post up my source for you canUrollwithTHIS and have you give me your 2 cents on it. oh and thanks for the reply.

Offline
alright here is my source for this so you guys can see it. its all done in the console. my next stage for developement is to make it into an applet...
this is all programmed in Eclipse.
java source

Offline
Oh sweet this is pretty cool. I'll just give you my 2 cents. Umm to take in user input I would personally use the Scanner class, as it's so much easier. Buffered reader is the old way, Scanner is so much more simplified, i'll show you an example of how it works below. Also when you make it in GUI, I personally think you should just make like an applet with 6 buttons on it, that way you don't literally have to draw out and x and an o. I think i made something like this in visual basic and thats what i did.
import java.util.Scanner;
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
String userInput;
userInput = in.nextLine();///<---in.nextLine(), basically reads in everything the userinputs until they hit enter.way easier than buffered reader
}

Offline
the buffer reader was the way my professor wanted it....
canUrollwithTHIS, am i going to need to make a new class to make this into an applet?

Offline
Yea you're gonna need a new class if you're gonna do an applet. You could do it as a JFrame as well (I prefer this, but to each there own), but regardless you'll need a new class. Also you're gonna have to change up your user input methods, as there will be no console to read in from. If you're gonna do buttons like i said, then each button has an "actionprefomed()" method, and you'll do it via that. If not you're gonna do this through a mouse listener. If i were you read the chapter on applets and the chapter on action listeners in your book. These things arent hard, but they are kinda funny to deal with the first time.

Offline
alright. i had a feeling that the CommandLineReader class will be taken out the second i decided to make it an applet.
do you use MSN canUrollwithTHIS by chance?

Offline