Results 1 to 15 of 15
  1. #1
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    JAVA programming.

    Hey everyone. I am looking for a kind kind soul to help me with java beginners programming. I'm not asking you to teach me the entire thing but sometimes I have questions that need answering. I would really really appreciate it. In return, internet kisses from a hairy man. Yes?
    Thanks.
    -Hygeio....

  2. #2
    King of Code thorrr's Avatar
    Join Date
    Aug 2008
    Location
    Montreal
    Posts
    1,770
    • Computer Specs
      • Motherboard: MSI P35 Platinum
      • Processor: Intel Core 2 Quatro Q6600 2.4GHZ OC TO 3.0GhZ
      • Memory: 2x2Gb DDR PC2-6400
      • Video Card # 1: XFX GeForce 8800GT 512Mb
      • Video Card # 2: XFX GeForce 8800GT 512 MB
      • Hard Drive # 1: Western Digital 500GB 7200 16Mb Cache
      • Hard Drive # 2: Western Digital 500GB 7200 16Mb Cache
      • Hard Drive # 3: Western Digital 1.0TB 32MB cache
      • Optical Drive # 1: Pioneer DVD+-RW
      • Power Supply: OCZ 700W
      • Sound Card: Realtek HD Audio
      • Monitor: Dell 20 widescreen & Samsung 21.6 Widescreen & Dell E2010H 20" Widescreen
      • Operating System: Windows 7 64bit
    Gold Donor
    New Server Contributor

    Re: JAVA programming.

    I'd be happy to answer any programming question you have!

  3. #3
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    Re: JAVA programming.

    cool, what's the best way to reach you? thanks man.
    -hygeio

  4. #4
    King of Code thorrr's Avatar
    Join Date
    Aug 2008
    Location
    Montreal
    Posts
    1,770
    • Computer Specs
      • Motherboard: MSI P35 Platinum
      • Processor: Intel Core 2 Quatro Q6600 2.4GHZ OC TO 3.0GhZ
      • Memory: 2x2Gb DDR PC2-6400
      • Video Card # 1: XFX GeForce 8800GT 512Mb
      • Video Card # 2: XFX GeForce 8800GT 512 MB
      • Hard Drive # 1: Western Digital 500GB 7200 16Mb Cache
      • Hard Drive # 2: Western Digital 500GB 7200 16Mb Cache
      • Hard Drive # 3: Western Digital 1.0TB 32MB cache
      • Optical Drive # 1: Pioneer DVD+-RW
      • Power Supply: OCZ 700W
      • Sound Card: Realtek HD Audio
      • Monitor: Dell 20 widescreen & Samsung 21.6 Widescreen & Dell E2010H 20" Widescreen
      • Operating System: Windows 7 64bit
    Gold Donor
    New Server Contributor

    Re: JAVA programming.

    thor@iogaming.net or the forums. But feel free to post the Q's in the forums as well..

  5. #5
    Subterranean Orange 1up_dave's Avatar
    Join Date
    Jan 2008
    Location
    Ohio
    Posts
    8,193
    Blog Entries
    1
    • Computer Specs
      • Case: CM Storm Sniper
      • Motherboard: Gigabyte EP45T-USB3P
      • Processor: Intel Q8400
      • Memory: 4GB DDR3
      • Hard Drive # 2: 40GB IDE
      • Optical Drive # 1: Sony DVD+/-RW DL
      • Power Supply: 400W
      • Monitor: 21" Acer
    Gold Donor
    Steam ID: wafflesandsyrup

    Re: JAVA programming.

    Posting on the forums will help others who may also be learning Java.


  6. #6
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    The Java™ Tutorials

    the source...

    CodeProject - For those who code

    best newsletter ever.

    be aware depending on what you are building for, it may not be what it seems - for example, android is not true java - its an altered 'native' java clone. what this means to you is basically nothing, unfortunately not all libraries are compatible with it though

    edit: and the most important thing you need to learn is the syntax - once you have that down, you basically know 60% of all languages out there(ie, theres only so many ways to set a bit)...


  7. #7
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    Re: JAVA programming.

    currently, I have this:

    public boolean isocelesTriangle()
    {

    if (((sideA == sideB) || ((sideA == sideC) || (sideB == sideC))))
    {
    return true;
    }
    {
    //Checks to see if Right Triangle
    if (((sideA * sideA) == ((sideB * sideB) + (sideC * sideC)))||((sideB * sideB) == ((sideA * sideA) + (sideC * sideC)))||((sideC * sideC) == ((sideA * sideA) + (sideB * sideB))));

    //Checs to see if Obstuse Triangle
    else if (((sideA * sideA) + (sideB * sideB) < (sideC * sideC)) || ((sideA * sideA) + (sideC * sideC) < (sideB * sideB)));

    {
    return true;
    }
    }

    }
    the arithmetic is fine. but what I want to do is the following. on my tester class. I have the following.
    else if (awesomeTriangle.isocelesTriangle())
    {
    System.out.println(awesomeTriangle.getSideLengths( ));
    System.out.println("This is a Isoceles Triangle ");
    System.out.println(("With an area of ") + awesomeTriangle.getArea());
    }
    the if else before this is fine. so dont worry abou it. What I want to do is for my systemout I want to print out "this is a triangle" if true for the right triangle boolean. how do I call this in systemout. meaning, if the right triangle is true how can I display it in my systemout. hopefully, this makes sense. Thanks.
    -JP.

  8. #8
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    Quote Originally Posted by Hygeio View Post
    currently, I have this:



    the arithmetic is fine. but what I want to do is the following. on my tester class. I have the following.


    the if else before this is fine. so dont worry abou it. What I want to do is for my systemout I want to print out "this is a triangle" if true for the right triangle boolean. how do I call this in systemout. meaning, if the right triangle is true how can I display it in my systemout. hopefully, this makes sense. Thanks.
    -JP.
    Code:
    if(myTriangle.isRightTriangle()) System.out.println("This triangle is a right triangle")
    Last edited by KRosen; 10-15-2012 at 11:46 PM.


  9. #9
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    just want to give some advice,

    Code:
    if (((sideA == sideB) || ((sideA == sideC) || (sideB == sideC))))
    this can be written without the nesting;
    Code:
    if(sideA == sideB || sideA == sideC || sideB == sideC)
    same with your other checks; right now, i can't read most of your code.
    the way it works is
    if(statement 1 is true) <--this if statement runs
    if(statment 1 is true && statement 2 is true) <-- this statement runs ONLY IF both are true; this is like putting if(myTriangle.isRight()) in the if statement; because the && is a statement of itself.

    you could technically do:
    boolean runIfStatement = (statement1 && statement2 &&statement 3) - and it will ONLY set your boolean to whatever is returned from the statement.

    last suggestion,it would probably be easier to just override the toString() method in your triangle object, and return a formatted string

    Code:
    @Override
    public Strhing toString()
    {
    String str;
    if(getIsIsocolese) str = "Isocolese Triangle Sides: "
    else if(getIsObtuse) str = "Obtuse Triangle Sides: "
     
    str = str+getTriangleSides();
     
    ....  
     
    return str;
    }
    then you can just call System.out. println(myTriangle.toString()) (or System.out.println(""+myTriangle) since the java subsystem will automatically call toString when you concat a nonstring object to an existing String)

    edit: something else you might want to do is rename your variables to something a bit more meaningful, if possible - you could have SideA be SideHypotenus instead - its a bit longer, but it tells you what it is just by the nature of its name.
    Last edited by KRosen; 10-15-2012 at 11:44 PM.


  10. #10
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    Re: JAVA programming.

    We havent learned that toString() yet. which would make this a lot easier. I was reading the instructions again last night and I thought it said that since an Isosceles is an acute, obtuse or right triangle that it must be under the same boolean. but it just says

    "If the triangle formed is Isosceles, then the string returned should be either Acute Isosceles, or Obtuse Isosceles. (A right triangle may also be isosceles, but this cannot occur with integer side lengths)"

    so what im thinking is making its own boolean for obtuse , acute, and right. and in each one I will put the isosceles code + the "&&" and the obtuse arithmetic. hopefully, that makes sense.

  11. #11
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    consider this - the whole point to Object Oriented Programming is abstraction, so COMPLETELY FORGET about the implementation for a momen -

    they want to know, if the Triangle is Isosceles or not.

    IF IT IS ISOSCELES, they want to know whether its acute or obtuse.

    you don't want to duplicated the isosceles code if you can help it - the other point of object oriented programing is code reuse - right?

    so you have a triangle object - and every triangle has to have what basic parts? ALWAYS make the simplest abstraction you can, to start with

    3 sides - you already have that part figured out.

    this next part is important - how do you classify different triangles?

    from wiki: Triangle - Wikipedia, the free encyclopedia
    equilateral traingle == all sides are the same
    isosceles triangle == 2 sides are the same
    a) acute == 2 equal sides < single side
    b) obtuse == 2 equal sides > single side
    scalene == no sides are the same

    so what is the best way to determine which one they are? there are DOZENS of ways to implement this.

    if you want to take a pure boolean approach, you can find out at the point of instantiation what they are, and fill booleans at the top. this is the method you use if you want your object to be immutable, which simply means that it can't ever be changed. if you take this route, i would suggest created a side method that fills the booleans for you and just call it from inside your constructor(NOTE YOU DON'T HAVE TO WRITE A HELPER METHOD, and some people would probably yell at you for doing it, but everybody has a different way of doing things - you could just as easily do it from within the constructor too):
    here is pseudo code for an idea of how you would do it
    Code:
    Triangle(side a, side b, side c)
    {
        //fill the sides of this triangle first
        fillMyBooleans();
    }
     
    fillMyBooleans()
    {
       if(//TEST FOR EQUALATERAL HERE) isEqualateral = true;
       else if(// TEST FOR ISOSCELES HERE) isIsosceles = true;
       else if(// TEST FOR SCALENE HERE) isSacelene = true;  
     
       if(isIsosceles)
      {
          if(//test for obtuse here ) isObtuse = true;
          else if(//test for acute here) isAcute = true;
          else is90Degree = true;  // your teacher said you wont need this one, but just adding it for completeness
       }
    }
    the other route, the one i would go, would be to simply make a method that will test at will what a triangle is
    you could have a method in your triangle object called
    boolean isMyTriangleIsosceles()
    {}

    and have it return TRUE if its an isosceles or false if it is not;
    you could have methods called isMyTriangleAcute and isMyTriangleObtuse (which is redundant for this exercise but you know, completeness)

    it would then be easy to create your triangle object, and then do

    if(myTriangle.isMytriangleIsosceles()) System.out.println("MY TRIANGLE IS ISOSCELES");
    or i guess in this instance you would then nest other if statements to determin if its acute or obtuse.

    edit: and i kind of forgot the point i was trying to get at with this, with abstraction - the biggest question is, HOW DO YOU WANT TO FIND OUT what this triangle is?

    do you want the triangle to always know? do you want the triangle to find out when you ask? in some immutable objects some would use a mix of both - by implementing the methods used to get the booleans like if you wanted to find out when you ask, but then just internally save the value so you don't have to do the math every time you ask.

    so that was my point by forgetting about implementation - the biggest and hardest part of programming is almost always figuring out how you want to do it, and knowing if it is the best way for what you want to do with it.

    edit2: and i forgot my other point - the way you SEEM to want to implement it is by not asking the triangle at all, but by using your tester method to figure out it - this is not usually the correct way to do it - this is an idea called encapsulation - if the triangle can figure out its own stuff on its own, let it - and then just ask the triangle what is up with it - this is much better than adding all the math into the tester because, what if your teacher asks you to do a different type of triangle?

    then you get to rewrite your tester with ALL THAT MATH - where as if you were to just let the triangle figure it out for itself, all you would have to do is add the new calls to the triangle object - since every new triangle you make is going to have the ability to figure out what it is for itself.

    then instead of rewritting tester methods you simply make a different triangle, and maybe call a different method (like isMyTriangleEquilateral instead)
    Last edited by KRosen; 10-16-2012 at 10:36 AM.


  12. #12
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    Re: JAVA programming.

    the assignment requires a tester class in where the user must input the three sides via the JOptionPane. the way you said you would do it, is the way im currently doing it. where i make a boolean method for obtuse acute etc. then on the tester class have if else after the object is created. i also have to systemout the area of the triangle and show what sides the person inputed and check to see if the input actually makes a triangle. thank you so much for all the help. midterm is on thursday. I think i got this exam by its throat

  13. #13
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    if you have trouble let me know, i'll see if i can't help ya out (note i haven't actually used any Swing stuff so that you are on your own for now)

    I am assuming you are using netbeans since you are using Swing?


  14. #14
    Hygeio's Avatar
    Join Date
    Jul 2012
    Location
    South Florida
    Posts
    59

    Re: JAVA programming.

    yes, it is such a resource hog. my laptop gives me the middle finger every time I open it.

  15. #15
    KRosen's Avatar
    Join Date
    Jan 2008
    Location
    :eek:
    Posts
    4,519
    • Computer Specs
      • Motherboard: XFX 680i
      • Processor: Core 2 Duo 3.0
      • Memory: 4G G. Skill 1000
      • Video Card # 1: eVga 8600 GT
      • Hard Drive # 1: Bunch of Seagates
      • Hard Drive # 2: A Single Maxtor
      • Optical Drive # 1: Crap Generic SATA
      • Power Supply: Good brand, forget the name
      • Sound Card: Razer Barracuda
      • Monitor: Acer 22"
      • Operating System: Windows Vista Ultimate (Free from club.live.com)

    Re: JAVA programming.

    Quote Originally Posted by Hygeio View Post
    yes, it is such a resource hog. my laptop gives me the middle finger every time I open it.
    i doubt you are allowed to change IDE's for your class, but i personally like eclispe - im not sure why, (other than that it is officially what the Android team uses) i guess i started using it before i tried netbeans, and just never got used to the netbeans setup.

    you can try searching StackOverflow for some tips on speeding up neteans:
    note i didn't read these thoroughly (usual heap size stuff is usual though)
    performance - Java Settings for Netbeans 6.8 on OSX 10.5.8 to optimize cpu usage - Stack Overflow
    java - How to improve Netbeans performance? - Stack Overflow


Posting Permissions

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