Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 65
  1. #21
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #23
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    Java 5 Early Objects by Tony Gaddis

  4. #24
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by s_dawg101 View Post
    Java 5 Early Objects by Tony Gaddis
    Then it should have a chapter on constructors that you might want to re-read. But I'm unclear on what you mean by "construct the constructor" as it's kind of a vague statement. What are you not able to do at the moment?

    Also, please re-read my link below on code tags as you're still not getting them right. You may wish to edit your current posts to put in correct tabs. If you do so, more here will be willing to read them and you'll likely get more and better help.

    Good luck.

  5. #25
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    how do i put the constructor in proper java form???

  6. #26
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by s_dawg101 View Post
    how do i put the constructor in proper java form???
    Again, your book will tell you how, and again, you aren't telling us what about this process you don't understand.

    I'm not trying to be difficult, but your question is very general and vague, and can only be answered by "read the book" or "check out the Sun tutorials". If you ask a more specific question, you'll likely get a more specific and helpful answer.

    Much luck!

  7. #27
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    i dont get what the constructor does or how i am suppose to use it in this sense????

  8. #28
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Constructors are for initializing objects. Sometimes they are created to accept parameters (as yours does for this assignment) if you want to use the parameters to initialize some of the fields in your class.

    You may benefit by reading another source on what constructors are and how to use them. Please have a look here: Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Again, much luck

  9. #29
    pellebye is offline Member
    Join Date
    Apr 2009
    Posts
    54
    Rep Power
    0

    Default

    Yes, good question, what is constructors for? It took me weeks (if not months) to get the idea back in time.

    Think of a class as a black box you cannot use to anything but make copies of. You can only use the copies (called instancies) and every time you make a copy you can give this copy different properties, in your case by giving different values for dX1, dY1 ... and so on. These properties, is your arguments for the constructor, which is used when you make a copy (an instance) of the class.

    After you have made an instance you can change that instance with the mutators, and get information about the instance through asseccors.

    In your program you can make several instances of your LineSegment class, and all these instances could you make with different arguments to the constructor. In that way they will all be LineSegments ... but different LineSegments.

    This picture of the class is far from complete, but I hope you can use it in your further process of learning.
    Last edited by pellebye; 10-12-2009 at 02:41 PM.
    -
    Life is not the worst thing we have ... in a few minutes my coffee is ready.

  10. #30
    Vio
    Vio is offline Member
    Join Date
    Oct 2009
    Location
    Belgium
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by pellebye View Post

    After you have made an instance you can change that instance with the asseccors, and get information about the instance through mutators.
    correct me if I'm wrong, but I think accessors is to get information en mutators is to change them. accessors => acces the information, mutators => mutation of the information

  11. #31
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by Vio View Post
    correct me if I'm wrong, but I think accessors is to get information en mutators is to change them. accessors => acces the information, mutators => mutation of the information
    Yep, accessors are the getters and mutators are the setters.

  12. #32
    pellebye is offline Member
    Join Date
    Apr 2009
    Posts
    54
    Rep Power
    0

    Default

    Yes, you are right ... I have just edited my information. Thank you.
    -
    Life is not the worst thing we have ... in a few minutes my coffee is ready.

  13. #33
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    i am so lost with this program right now.

    could somebody get me started????

  14. #34
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    The longer a thread gets the less the chances of a solution being arrived at.

  15. #35
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    How are you lost? What steps have you created that don't work or what steps do you not have a clue? Perhaps you should post your current best code.

  16. #36
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    i am just so lost with all of this stuff. can somebody just show me how they would start it

  17. #37
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by s_dawg101 View Post
    i am just so lost with all of this stuff. can somebody just show me how they would start it
    Based on earlier posts, you've already started this class. Based on your current posts we have no idea how to help you other than to say the Sun tutorials are here: Sun Tutorials Big Index

    I'd love to help you, I really would, but without specific questions, it's going to be hard if not impossible to. I do wish you much luck regardless.

  18. #38
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    Java Code:
    public class LineSegment
     {
     	private double x1;
    	private double x2;
    	private double y1;
    	private double y2;
    	private double length;
    	private double MidPoint;
     
    	public LineSegment( double dX1,double dY1,double dX2,double dY2 ){
    		x1 = dX1;
    		x2 = dX2;
    		y1 = dY1;
    		y2 = dY2;
    	}
    	
    	public void setx1(double dX1){
    		x1 = dX1;
    	}
    	public void setx2(double dX2){
    		x2 = dX2;
    	}
    	public void sety1(double dY1){
    		y1 = dY1;
    	}
    	public void sety2(double dY2){
    		y2 = dY2;
    	}
    	public double setlength(double newlength){
    		length = newlength;
    		newlength = math.sqrt(math.pow(x2+x1,2)+math.pow(y2+y1,2));
    	}
    	public double setMidPoint(double newMidPoint){
    		MidPoint = newMidPoint;
    		newMidPoint = (x1+x2) / 2; (y1+y2) / 2;
    	} 
    		
    	public double getx1(){
    		return x1;
    	}
    	public double getx2(){
    		return x2;
    	}
    	public double gety1(){
    		return y1;
    	}
    	public double gety2(){
    		return y2;
    	}	
    	public double getlength(){
    		return length;
    	}
    	public double getMidPoint(){
    		return MidPoint;
    	}
    		
    	
     }

  19. #39
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

    Default

    LineSegment.java:38: not a statement
    newMidPoint = (x1+x2) / 2; (y1+y2) / 2;
    ^
    1 error

    this is the error that it says

  20. #40
    s_dawg101 is offline Member
    Join Date
    Oct 2009
    Posts
    49
    Rep Power
    0

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Child-Class Calling a Method in a Parent-Class
    By Blah_ in forum New To Java
    Replies: 5
    Last Post: 09-29-2009, 02:48 AM
  2. Replies: 7
    Last Post: 05-06-2009, 12:42 PM
  3. Replies: 8
    Last Post: 03-21-2009, 09:34 AM
  4. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  5. Class Reflection: Finding super class names
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:12 PM

Tags for this Thread

Posting Permissions

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