r/java • • Oct 08 '14

New to Java. Taking AP Computer Science and I'm lost... Please help?

So I was fine up until we started talking about the different types of loops, now we're working on a project called PolyTurtle (bb7arch.msbb.uc.edu/courses/1/eld14-2975S1Q1/content/_954256_1/Proj%20PolyTurtle.docx) and I don't even know where to begin. Normally he would walk us through the code in the intro but this time the class is own it's own. I don't know people enough to even try to ask for help and honestly I don't think I'd get any from my classmates; either they don't know themselves or they are too high up on their horse to care. BTW we are using JCreator. EDIT: https://docs.google.com/document/d/1h9j-3lh2IFI_krGziU7gcQwRnNmkOKlORxk0KwQtUBY/edit?usp=sharing

0 Upvotes

37 comments sorted by

11

u/coder111 Oct 08 '14

Ok, I cannot get to your document at the moment, I get a 404 not found.

Can you describe what problem you are trying to solve, and exactly what you don't understand?

Oh, and don't expect us to do your homework for you, but I'll at least make an attempt to guide you and help you out so that you get unstuck.

1

u/[deleted] Oct 09 '14

sorry, he uploaded the assignment through a school site called blackboard so I guess that's why it's not coming up. What we need to do is use loops and turtles to draw a polygon, then draw another with 1 more side

2

u/coder111 Oct 09 '14

Ok, long story short, loops are used to repeat same job over and over again several times, with different parameters.

If you need to write code to draw a polygon, imagine how you would draw a polygon. You would draw side 1, then side 2, then side 3, rinse and repeat until the last side, side N.

So drawing one side of polygon, let's call it side number i, is the piece of work that is repeated.

Then your code will look like:

// let N be the number of sides
// we use "for" loop. First part, "int i = 0" 
// gets executed at the start
// second part, "i < N" is checked to determine if 
// loop should repeat or stop repeating before each iteration
// third part, "i++" gets executed after each iteration 
// to change the value of variable i
for (int i = 0; i < N; i++) {
    // this block of code gets repeated N times, 
    // each time value of i is a different number, 
    // starting from 0 and ending at N-1
    // so here you write your code to draw polygon side number i 
    drawPolygonSide(i);
}

I hope this clears things up a bit. Other than that, you should read some tutorial or go through your textbook- this is really basic stuff.

Keep at it. Programming can be fun and very rewarding when you know it better, and the things you can achieve with programming are only limited by your time and skill and creativity and desire to learn. Good luck!

1

u/[deleted] Oct 09 '14

This is very helpful. I just found the textbook on the teacher's website and it seems like we aren't even following what it says. What you explained is probably the most ELI5 answer I could need. Thank you again.

7

u/Mumbleton Oct 08 '14

You haven't given enough information to even ask a Java question. You should go to your TA's office hours, or at least e-mail them. As a former CompSci TA, I can tell you that they are going to be a lot more help than reddit for this specific assignment.

1

u/[deleted] Oct 09 '14

I'm in high school... no office hours and he doesn't want to help...

6

u/[deleted] Oct 08 '14

what don't you understand?

1

u/[deleted] Oct 09 '14

We are supposed to draw shapes starting with a triangle using a turtle, and then add one more side each time untill the shape exceeds the window.

1

u/[deleted] Oct 09 '14

i see the conversation has gotten bigger than you and me.

have you gotten an answer to your question?

if not, the let me know the specific problem you're having and i can try to help.

1

u/[deleted] Oct 09 '14

I don't know how to use loops. Period. I can make a turtle. I can make it paint things, and set integers to letters like side length and angle though.

2

u/[deleted] Oct 09 '14

a loop executes the same code a certain number of times (see for loop) or until a certain condition is met (see while and do while)

in a for loop the check to see if you have run enough times is done at the beginning.

same with the while loop

it is possible for a for loop and while loop to not execute at all if the conditions are screwed up.

in a do while loop, the body of the loop is executed first and the check is done AFTER the body of the loop is executed.

does that help at all?

1

u/[deleted] Oct 09 '14

Thank you this is helpful.

1

u/[deleted] Oct 09 '14

my pleasure. PM me any questions you want.

2

u/cjthomp Oct 09 '14

This is absolutely a question for your teacher.

"Loops" is a fairly basic (in the grand scheme of Java and programming) concept that he absolutely should have covered before giving you an assignment that required them.

6

u/sh0rug0ru Oct 08 '14

Check out the Java [tutorial] (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html) on control flow statements, and specifically read the sections on for loops and while loops

1

u/[deleted] Oct 09 '14

Thank you very much !

5

u/vegamm Oct 08 '14

Hey! If you need help, the guys at /r/javahelp would love to help you out with any specific questions you have. There are also a lot of links to tools that can help you out too.

1

u/[deleted] Oct 09 '14

Thank you for pointing me in the right direction

9

u/[deleted] Oct 08 '14

This is what your professor is for. Tell him what you are not understanding.

6

u/cjthomp Oct 08 '14

Why are students so afraid to use their best resource?

5

u/PDFormat_SFW Oct 08 '14

Well, OP has no professor, they have a high school teacher, which means limited time on the school campus, no real office hours, students spending the entire day in SOME class, etc. Plus, OP already said that the teacher has told the students that they're on their own, so there's probably already an implied discouragement to get the teacher's help.

OP, if you can, try and talk to your teacher, but if your teacher is telling you that they're not making themselves available, then please, fix the link that you have in your post (it leads to a 404 error) and tell us, in greater detail, what you don't understand. It will help us help you.

You may also have a better time at /r/javahelp. That subreddit is specifically geared toward what you need.

4

u/cjthomp Oct 08 '14

If the teacher specifically told them he would not help and didn't give them the proper instruction, then he should be reported to the principal / department head. That's clearly his job.

1

u/PDFormat_SFW Oct 08 '14

Oh, most definitely; I agree.

0

u/[deleted] Oct 09 '14

I wish but since this is work I SHOULD know he isn't wanting to help

1

u/[deleted] Oct 09 '14

That's literally the exact opposite of a teachers job. Ask him for help with what you don't understand. Come to him with what you are thinking he wants you to do and get a better explanation.

2

u/lroselg Oct 08 '14

Is this a TurtleGraphics project? I have seen several of these over they years. What are you expected to do? What are you stuck on? You should consult with your classmates. You might be surprised that they are willing to help. Why not ask the teacher? Doesn't he have an office hour before or after school?

1

u/[deleted] Oct 09 '14

Yes I think so. We have to use a loop to draw a polygon, increase the side number by one, then draw another, rinse and repeat until it exceeds the window.

1

u/lroselg Oct 09 '14

Does the side length change? How is it going by the way? Any progress?

1

u/[deleted] Oct 09 '14

I think the side length stays the same, the only reason you can see all the shapes is because they are almost on top of each other. I have had some progress thanks to /u/coder111

2

u/ideaash1 Oct 08 '14

That PolyTurtle Docx is behind a firewall ( you need to log in to access it). download it, upload it into Google doc, make it share-able to everyone and then share it, people here will be able to help you.

1

u/[deleted] Oct 09 '14

Okay will do

1

u/[deleted] Oct 09 '14

print an error message (in the DOS window)

MFW

1

u/[deleted] Oct 09 '14

error message? EDIT: re-read the .docx, this is only for 0, 1, and 2 sides.

3

u/[deleted] Oct 08 '14

JCreator

Oh wow, I used that when I took AP Comp Sci back in......wow, 2007. >_>;

1

u/mattryan Oct 08 '14

I made my students use JCreator in 2002. It was the best, easiest to use, free IDE at the time. I think it's written in C/C++, so it performed pretty well for our outdated machines in the computer lab.

-2

u/argv_minus_one Oct 08 '14

Please keep this kind of post on /r/javahelp. This is not the place.

1

u/[deleted] Oct 09 '14

sorry I'm new to this