Jump to content

Help with basic java!

- - - - -

  • Please log in to reply
12 replies to this topic

#1
heartybowl

heartybowl

    Newbie

  • Members
  • PipPip
  • 17 posts
So I'm taking a beginner's java class and i don't get how to do my homework assignment! :(

this is what my teacher wants me to do.
"start DrJava (fresh, with no other apps open) and create a new console-mode application in the week01 folder.

* Name the program TicTacToeBoardPrinter.
* The output of the program should look like this:

      +---+---+---+

      |   |   |   |

      +---+---+---+

      |   |   |   |

      +---+---+---+

      |   |   |   |

      +---+---+---+


Don't put any spaces around your tic-tac-toe board. You should have exactly seven lines of output.
* Once you have created the program, compile it and run CheckResults to see your score. Keep trying until you get a perfect score.

To submit this assignment, run Run CheckResults and then upload hw02.dat which you'll find in your week01 folder. Use the Blackboard assignment drop-box to upload the file. (Only submit your own work, of course.) "

I just don't know what I'm suppose to type into drjava to make that tic tac toe thing to show up! he just threw us in the waters without explaining. he's so fast pace and didn't really tell us what to type. We made a thing in drjava that says "hello world". and he literaly had us copy and paste the code into dr java which doesn't help me at all because im just copying and pasting and i don't know why im putting those things in there.

so can someone help me please?

Edited by dargueta, 01 February 2011 - 06:30 PM.
Added code tags


#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
So is your problem figuring out how to write the code, or using drjava?
sudo rm -rf /

#3
heartybowl

heartybowl

    Newbie

  • Members
  • PipPip
  • 17 posts
yes, how to write the code

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
We gladly help with homework, but we won't do it for you. What do you have so far?
sudo rm -rf /

#5
heartybowl

heartybowl

    Newbie

  • Members
  • PipPip
  • 17 posts
here's the thing... I have nothing. I've only had 2 class sessions with him and like I said in the original post, He didn't explain anything to us. He just told us to open up drjava and to copy his code onto dr java and now he expects us (my class) to make a tic tac toe program. :/

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Judging from the directions, all it needs to do is print out a tic-tac-toe board. If you can write a Hello World program, you can write this.
sudo rm -rf /

#7
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Double posting because of a PM the OP sent me:

Quote

dargueta. I don't know how to make a code that says "hello world"

my teacher told us to copy HIS CODE and paste it into drjava.

for example, his code would be something like
}#)*(
#*$()klJDf "hello world"
293e 032jkehg
4345

so then we all had to copy
and paste that.

He didn't teach us why those things were there or what they mean, even all my class mates were like "what the heck?"

Can you post his actual code? I can point out to you how it works if I see it.
sudo rm -rf /

#8
heartybowl

heartybowl

    Newbie

  • Members
  • PipPip
  • 17 posts
Ok this is what his code looks like


/**

 * My first console program for CS 170.

 *

 *@author (your name goes here)

 *@version (place the date here)

 */

public class MyFirstConsoleProgram

{

     /**

      * These are the commands your pogram will carry out.

      */

     public static void main(string[] args)

     {

          System.out.print("hello, I love you. ");

          System.out.println("Won't you tell me your name?");

          System.out.print("My name is Stephen Gilbert,");

          System.out.print("by the way.");

      }

}


So that's the code he gave us

#9
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
If you're new to programming this might be very difficult if the lecturer just gave you this information! lol

If I were a teacher, I'd tell you that print and println are methods.
What they do is output to the console/screen whatever.
Example:
System.out.println("--ABC---");
This would output the following to you:
---ABC---
Println adds a newline to the end of the current line.
Print does not add a newline to the end of the current line.
Example:
System.out.print("abc");

System.out.print("def");
would output like this:
abcdef
From this might information you might be able to produce the expected output.

#10
mr mike

mr mike

    Learning Programmer

  • Members
  • PipPipPip
  • 96 posts
This should help you


public class MakeAName{

      /*

         This is your main method. It is needed to run any java program.

          String [] arrrr is a command line input - you wont have to worry about this

          now. notice- you professor put args and i put arrrrr. This is because its only a 

          variable name for a "String []" array.

      */

      }

      public static void main(String [] arrrrrr){

              // Your professor just wants you to put out 7 S.O.P. statements

             // they are only print statements System.out.print = one line 

             // System.out.println("multiple line") 

            // here is the first two lines

             System.out.println("+----+-----+-----+");

             System.out.println("|    |       |       |");

             // now you should be able to finish

             // just make sure you line em up each line

             // it will come out 

      }// end of main method

}// end of class


Edited by mr mike, 01 February 2011 - 08:23 PM.
bad spelling


#11
heartybowl

heartybowl

    Newbie

  • Members
  • PipPip
  • 17 posts
oh wow that helped a lot. Ya my teacher did not tell that to us at all...
And this is the lowest level class for programming! And he's the only java teacher at my college so I had no other choice. :(
I guess i could just insert the tic tac toe image into his code but i wouldn't be learning as much as i would like to

#12
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP

Quote

I guess i could just insert the tic tac toe image into his code but i wouldn't be learning as much as i would like to
Try it! See what happens when you do. If it works on the first try I'd be surprised.
If it doesn't output like you want, then that's where the fun tweaking begins and you begin to learn about the language.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users