• Post Reply Bookmark Topic Watch Topic
  • New Topic

need help finding a bug, please  RSS feed

 
Leon finkel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone, can someone look at my program and help me find the problem that the taster found?

my prog---->





the taster:
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help us help you - what output did you get when you ran the PointTester class?

It looks like it prints out sensible error messages that give you a hint about what's wrong. Did you try to find out yourself what the error message was telling you? What was your conclusion?
 
John Joe
Ranch Hand
Posts: 432
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are your problem?
 
Leon finkel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
********** Test Q1 Point - Start **********
testing first constructor and getters:
OK - default constructor and getters expected (0.0, 0.0) actual=(0.0, 0.0)
ERROR - default constructor and getters expected (0.0, 4.0) actual= (0.0, 3.5759866544022314)
OK - default constructor and getters expected (3.0, 0.0) actual=(3.0, 0.0)
ERROR - default constructor and getters (x, y): expected(3.3, 4.4); actual=(0.0,1.5039601647369094)
testing copy constructor:
ERROR - copy constructor (other p): expected(3.3, 4.4) ; actual=(0.0,1.5039601647369094)
testing setters:
ERROR - setX point was (3.0,4.0) set x to 5.0 expected (5.0, 4.0) actual= (5.0000649568571145, 1.3671354677607739)
ERROR - setY point was (3.0,4.0) set y to 5.0 expected (3.0, 5.0) actual= (0.0, 4.999999999966269)
testing equals:
OK - p1.equals(p2) expected true ; actual=true;  p1=(3.5033096433243656,0.0) p2=(3.5033096433243656,0.0)
testing isAbove:
OK - p1.isAbove(p2) expected true ; actual=true;  p1=(3.683272369243531,2.536372027910564) p2=(3.5033096433243656,0.0)
testing isUnder:
OK - p1.isUnder(p2) expected true ; actual=true;  p1=(3.5033096433243656,0.0) p2=(3.683272369243531,2.536372027910564)
testing isLeft:
ERROR - p1.isLeft(p2) expected true ; actual=false;  p1=(3.683272369243531,2.536372027910564) p2=(0.0,1.3672365133971902)
testing isRight:
ERROR - p1.isRight(p2) expected true ; actual=false;  p1=(0.0,1.3672365133971902) p2=(3.683272369243531,2.536372027910564)
testing move:
ERROR - p0 was (1.0,1.0) p0.move(2.0,2.0) expected p0(3.0,3.0); actual=(2.742820143290952,3.2033909379839054)
testing distance:
ERROR - p0.distance(p2) expected 5 ; actual=3.3772857805801673 p0=(0.0,0.0); p2=(3.3772857805801673,0.0)
********** Test Q1 Point - Finished **********


this is the resulte but i didn`t understand what ca i do to fix the problem
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and welcome to the Ranch.

There are tons of issues with your code.

Starting with indentation and moving along with code bits like:

As you see you don't use braces, hence you don't get what might think getting.

I'd suggest first, stop messing around, meaning, format and indent code properly. Remove preceding underscores from all places where you have _variableName.

And repost code probably.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm very interested to know, how you manage to get formatting and indentation that way? Would you mind to attach screenshot how that looks in your programming environment?

I just tried to choose an editor from Windows OS which has least capabilities (Notepad) and copied some code from IDE to it, and it manages to preserve formatting and indentation correctly.
So wondering, what you do in order to get your way? Note, you are not alone in these forums who have code like that, possibly there is something fundamentally wrong in thinking that it isn't important, we need to change that thinking in case of it.
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Crossposted at Java Forum, where I've noted that there seems to be a fundamental flaw in what this Point class is supposed to represent.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OP
We don't mind for cross posting here, but you should mention that beforehand. One simple reason - so the guys wouldn't repeat things which have been mentioned already by Dave there. In short - so you wouldn't waste people time whoever trying to help you.

That kind of thing needs to be done in every forum you post, not just here, unless specified otherwise. But usually this is a common practice.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!