Results 1 to 12 of 12

Thread: Java

  1. #1
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Los Angeles/Hong Kong
    Posts
    3,058

    Java

    It seems to me that there are loads of knowledgeable people in the comp-sci field in this section.
    Hope you guys don't mind if I post it here.

    I am doing AP Comp Sci in high school right now.

    But the thing is, I don't have a good teacher. My teacher is the ones that gives you a PowerPoint slideshow just explain each slide to you.

    I did okay through the first semester, learning about nested loops, arrays, and all those basic stuffs.

    But now we are introduced with interface, comparable, abstract... Stuffs like that. I barely learned anything.

    Test is tomorrow and I really need a reputable source for learn Java.

    Yeah I am pretty screwed...
    Team XS: xs4s.org



  2. #2
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Texas
    Posts
    5,152
    Not sure that we can help you to much before the morning, but post up some questions and we'll try...

    If you want to call quick PM me and I'll see what I can do. IDK how much of the obscure terms I remember though.


    24 hour prime stable? Please, I'm 24/7/365 WCG stable!

    So you can do Furmark, Can you Grid???

  3. #3
    Xtreme Member
    Join Date
    May 2009
    Location
    Hull, England
    Posts
    467
    I've got no background in Java (only C and C++ really) but I'll answer any questions I can.

  4. #4
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Los Angeles/Hong Kong
    Posts
    3,058
    Thanks for the quick replies.

    Well here is one of the worksheet the instructor gave us, stating that it will be a "potential free response." The Word document is below.

    That's what I got so far:
    Code:
    Public Dot()
    {
    
    }
    
    Public Dot (int x, int y)
    {
    
    }
    
    Public Dot (int x, int y, int size)
    {
    
    }
    Attached Files Attached Files
    Team XS: xs4s.org



  5. #5
    Xtreme Member
    Join Date
    May 2009
    Location
    Hull, England
    Posts
    467
    I don't think I'll be of much use to you.

  6. #6
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Texas
    Posts
    5,152

    Post

    Code:
    public class Dot() implements Locatable
    {
    ....int YPos;
    ....int XPos;
    ....int DSize;
    
    ....public int getXPos() //because it implements Locatable it must fulfill these function requests.
    ....{
    ........return XPos;
    ....}
    
    ....public int getYPos()
    ....{
    ........return YPos;
    ....}
    
    ....public Dot()//initialize to default values, 0 could be any default you want
    ....{
    ........int YPos = 0;
    ........int XPos = 0;
    ........int DSize = 0;
    ....}
    
    ....public Dot (int x, int y) //use provided, otherwise default
    ....{
    ........int YPos = x;
    ........int XPos = y;
    ........int DSize = 0;
    ....}
    
    ....public Dot (int x, int y, int size) //everything provided.
    ....{
    ........int YPos = x;
    ........int XPos = y;
    ........int DSize = size;
    ....}
    
    ....public String toString ()
    ....{
    ........return "x = " + XPos + ", y = " + YPos + ", size = " + DSize;
    ....}
    Note: Public must be public, capitalization matters.
    Also, you'll have to remove the ...s, that was just for spacing cuz it wouldn't take tabs.
    Last edited by Otis11; 01-27-2011 at 09:31 PM.


    24 hour prime stable? Please, I'm 24/7/365 WCG stable!

    So you can do Furmark, Can you Grid???

  7. #7
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Los Angeles/Hong Kong
    Posts
    3,058
    Quote Originally Posted by Jacka View Post
    I don't think I'll be of much use to you.
    Well, thanks for dropping by.

    Quote Originally Posted by Otis11 View Post
    Note: Public must be public, capitalization matters.
    Also, you'll have to remove the ...s, that was just for spacing cuz it wouldn't take tabs.
    Gosh that's fast..
    Loved the side comments!
    Can you explain more in depth on the "public class Dot() implements Locatable" part?

    You are a life saver!
    Team XS: xs4s.org



  8. #8
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Texas
    Posts
    5,152
    Quote Originally Posted by lkiller123 View Post
    Well, thanks for dropping by.



    Gosh that's fast..
    Loved the side comments!
    Can you explain more in depth on the "public class Dot() implements Locatable" part?

    You are a life saver!
    Um, yeah... you have to have all of these things contained within a class, just like your main method is contained within a class. The public is because you want to be able to make dot objects outside of the class, class designates it's a class, Dot() is the name of the class - this must be the same name as your constructor, and if you want to implement another class you simply say implements such-and-such. The only thing is if you say implements you MUST DEFINE EVERY METHOD within the class you are implementing... I didn't realize that till after my test back when I took it, and it hurt.

    If you have any other questions I'll be up at ~6:15 am your time and I'll check this before I run to class.

    Hope that answers it for ya.

    Oh, and not that it matters, but it's good coding practice to put your constructors before your accessor methods... I didn't do that. Sorry.


    24 hour prime stable? Please, I'm 24/7/365 WCG stable!

    So you can do Furmark, Can you Grid???

  9. #9
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Los Angeles/Hong Kong
    Posts
    3,058
    Quote Originally Posted by Otis11 View Post
    Um, yeah... you have to have all of these things contained within a class, just like your main method is contained within a class. The public is because you want to be able to make dot objects outside of the class, class designates it's a class, Dot() is the name of the class - this must be the same name as your constructor, and if you want to implement another class you simply say implements such-and-such. The only thing is if you say implements you MUST DEFINE EVERY METHOD within the class you are implementing... I didn't realize that till after my test back when I took it, and it hurt.

    If you have any other questions I'll be up at ~6:15 am your time and I'll check this before I run to class.

    Hope that answers it for ya.

    Oh, and not that it matters, but it's good coding practice to put your constructors before your accessor methods... I didn't do that. Sorry.
    Yeah dude that gave me lots of help.
    I got this; totally ready to ace the test.

    Coding is not as easy as it seems, but I am definitely getting a hang of it..
    Hope you won't mind if I spam you more PMs in the future.
    Team XS: xs4s.org



  10. #10
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Texas
    Posts
    5,152
    Go for it man, spam away. I'll try to help as much as I can.


    24 hour prime stable? Please, I'm 24/7/365 WCG stable!

    So you can do Furmark, Can you Grid???

  11. #11
    Xtreme Enthusiast
    Join Date
    Jun 2008
    Location
    Northern Ohio
    Posts
    664
    Quote Originally Posted by lkiller123 View Post
    But the thing is, I don't have a good teacher. My teacher is the ones that gives you a PowerPoint slideshow just explain each slide to you.
    Unfortunately this is something you are going to have to prepare for. If your degree goes anything like mine did (only been out of college for 5 years) you'll almost always have the power point lessons. I personally stopped going to classes my junior year because I could learn just as much by going over their slides sitting at home (since they were usually posted online).

    The most you can do is hope that you have a professor with flexible office hours to help you outside of class, and just trying to understand each slide as it's shown because if you are lost on the first one you will be overwhelmed by the last one.


    Work/Game System - ~24/7 WCG
    ASUS P8P67 PRO / i7 2600k @ 4.1Ghz / Gigabyte Radeon HD5870 / 4x4GB Corsair Vengeance @ 1600Mhz 9-9-9

    HTPC -~24/7 WCG
    Gigabyte GA-Z68AP-D3 / i7 2600k @ 4.0Ghz / Sapphire Radeon HD5830 / 2x2GB Mushkin Enhanced Essentials @ 1333Mhz 9-9-9

    XS WCG Team Forum - http://www.worldcommunitygrid.org/

  12. #12
    Xtreme Cruncher
    Join Date
    Oct 2007
    Posts
    1,638
    Java is an Indonesian island famous for their coffee which is named after the island!!

    <--- Also utterly useless
    XTREMESupercomputer: Phase 2
    Live up to your name - November 1 - 8
    Crunch with us, the XS WCG team

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •