| |
| |
| |
|
Page: 1 2 3 4 5 6 7
Comments:
<0> rickety: :::O) <1> hehe <1> java newbie beginner here..just 1 week at java and OOP..:( <1> cant get used to the system..thanks for any attention here.. <2> Setx is a bad name, setX is better. <3> hi <2> Ditto for getX. <0> setters ****. <0> :) <1> sorry this was a given code :( <2> Line 34 will give a NullPointerException. <1> hm it breaks on the Emvado method... <2> Line 40 will not compile, you're trying to use the return value of a method that doesn't have a return value. <1> [emvado = area in greek] <1> yes <1> thats my prob
<1> how can i store <1> the points.. <1> so that i can calculate the area; sorry for broken text here...:( <2> They're already stored. <2> They're in p2 and p1. <1> and how do i write this in the return ; <2> Do you mean "how can I get the values?"? <1> hmm <1> yeap! <0> second constructor: do p1 = new Point (x1, y1); p2 = new Point (x2,y2); <0> instead of setting to nonexisting points <2> You want to know how to *get* the *x* value from a *Point*? <1> one at a time :) <2> motel: Kindly explain what lines 23 and 28 do. <2> 23 to 28, inclusive, I mean. <0> oh btw <0> why do you invent your own Point's <1> ah they give the x and y given before in Setx Sety... <0> did your instructor told you so? <0> :) <1> what do you mean there; <0> java.awt.Point <0> java.awt.Rectangle <2> motel: But you're not using them. That suggests that you probably should be using them, or they shouldn't be there. <0> :P <2> java.awt.Point uses doubles in its API, iirc. <1> rickety yeap you're right.. <2> I reimplemented Point in my code ;) <1> hmm lets see how i can use these.. <0> rickety: so what... <0> i do point.x point.y <0> never getX <2> I use interfaces where possible/practical. <1> BUILD SUCCESSFUL (total time: 0 seconds) <2> I don't use point.x and point.y because it's inconsistent with the rest of my codebase. <0> calling function makes ~20 ***embler commands, getting value directly at most 3. <1> return (p2.Getx()-p1.Getx())*(p2.Gety()-p1.Gety()); <0> :)) <2> motel: Now await the NullPointerException. <1> hm.. <1> hmm <0> rickety: i try to avoid lame function calls <1> how can i produce this error?:) <2> motel: Don't worry, you will. <2> wolfey: HAHAHAHA <0> # public cl*** Rectangle{ <0> # public Point p1; <0> # public Point p2; <0> # <2> wolfey: Go on, tell me why. I could do with a laugh. <0> motel: if you want this way: public Poin <0> public Point p1 = new Point(); <0> public Point p2 = new Point(); <0> dont set values on null references <2> wolfey: I do actually recommend that way to beginners, especially those who don't understand constructors. <2> I also recommend final on fields, to people of middling ability. <0> what way? <2> public fields. <1> rickety he asked for private..for some reason.. <0> :)) <2> motel: It's called encapsulation. It's a good practice, but newbies often get confused by getX and setX kind of methods.
<1> i can tell why !;) <1> hey..once you start to get used to the object method cl*** thing.. <0> LESSON 35234523: If you provide setters, make variables private. You need setters if you calculate other variables from one being set. <1> it's really smart..:) <2> wolfey: http://en.wikibooks.org/wiki/Java_Programming/Preventing_NullPointerException <0> im too lazy to read <0> anything i dont yet know? <2> I'm too lazy to read your mind. <0> i did from java2d through swing to rmi, sql and xml <0> i know how to solve null ponters <0> pointers <0> :) <1> ehm...where's the main cl*** now..dammit <2> Preventing and solving are different. <0> well error doesnt exist until i see it <0> then i fix it <1> hmm <2> If it takes you X seconds to fix an NPE, and X-Y seconds to prevent an NPE, then over a year that might add up to a few extra drinks in a pub. <2> Where Y is positive and less than X. <0> ::))) <0> i love you rickety <0> you fun <0> :) <1> http://hashphp.org/pastebin.php?pid=6482 <1> hm my NETBEANS sais it cant find the main cl***... <0> :) <0> default is Main <4> are you trying to run it from the Point cl*** ? <2> motel: Exit Netbeans. <2> wolfey: Just for fun: http://www.swingwiki.org/best:using_a_factory <1> done <2> motel: You have no main method. <1> public void main(String[] args) { <1> Rectangle R = new Rectangle(2,2,1,1); <1> System.out.println(R.Emvado()); <1> } <1> } <1> ?.. <4> its not static <1> so much to learn... :-/ <1> hm..still no run <2> What error? <1> no main cl*** found <4> cl*** ? <2> motel: That error is from Netbeans. You said you'd exited Netbeans. <1> rickety and run it from command? <2> Yep. <1> can you explain why?:) <4> Will the Points be created as long as you're calling the other constructor ? <2> Or from an editor. Newbies shouldn't use IDEs. <1> i dont get it:( <2> IDEs obscure processes, mainly because they're intended for non-newbies. This confuses newbies. <1> Point is my main cl***.. <1> i see.! <2> motel: Where is your main method? <1> at the end of the code.. <1> ; <2> What is the name of the cl*** it is in? <1> public cl*** Point{ <4> no <2> motel: Try formatting your code, and read again. <1> hm.. <1> i dont know what should inside the { } of the other... <4> hmm.. I dont see a closing } for the Point cl***, is the pastebin correct ? <1> should cl*** point have all in the { } ? <1> yep..pastebin correct,me wrong <1> grmf..too many { } , lost it now completely <0> rvsjoen: are you the one that tried my game?:) <4> yes <4> its still sitting on my desktop <4> :P <2> motel: Ok, you seem to have a cl*** inside a cl***, which, for a newbie is WRONG. <0> 'final' version http://86.61.29.5/homepage/ <0> rvsjoen: ...
Return to
#java or Go to some related
logs:
hornylosers.
who is easypwn
hungarian is like
#linux lizbjani #linux too high for the supermarket #java benesante #chatzone
|
|