Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I need some help with inheritance methods.

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question I need some help with inheritance methods.

    I am currently enrolled in an online course for AP Computer Science, and it is becoming confusing without a teacher to ask questions to. I am having some difficulty with inheritance methods. In this course I am using BlueJ as a compiler and the textbook is "Java Au Naturel" by William C. Jones. My assignment that I can't finish is as follows:

    Exercise 1.12* Write a StarTurtle class with two instance methods: One draws a five- point star (hint: turn 144 degrees) and one draws a six-point star (two overlapping equilateral triangles with symmetry). Make them 60 pixels per line segment. // I've done this part, it was not a problem at all, 1.13 is the difficulty.
    Exercise 1.13* Write an application program that uses a StarTurtle object, as defined in the preceding exercise, to make an interesting drawing with at least five stars in it.

    The wording in the book is a little confusing about inheritance. In BlueJ I have three classes, Turtle, TurtleT, and the one that I use to program. I quite honestly have no idea where I go to do inheritance. Do I make another class? Or another method? Just lost.

    Here is what I had for 1.12 if it helps:

    public class StarTurtle extends Turtle
    {
    // Draw a 5 pointed star, 60 pixels per line, 144 degree turn
    // Draw a 6 pointed star. (Two equilateral triangles)

    public void make5star() {
    star.paint (144, 60); // All 5 of these create a side of the star
    star.paint (144, 60); //
    star.paint (144, 60); //
    star.paint (144, 60); //
    star.paint (144, 60); // end star
    } // this right-brace marks the end of the main method
    public void make6star() {
    star6.move (-180, 200); //Gets away from the first star
    star6.paint (120, 60);
    star6.paint (120, 60);
    star6.paint (120, 60); //First triangle complete
    star6.move (90, 30); //Move away from triangle
    star6.paint (90, 60);
    star6.paint (120, 60);
    star6.paint (120, 60); //Second triangle complete
    } // this right-brace marks the end of the main method
    }


  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need some help with inheritance methods.

    hey man, im on this same exercise, can you help me with 1.12?? im even trying what you did and i dont understand the issue. if you can get back to me i would REALLY appreciate it!!

Similar Threads

  1. hi need help with inheritance
    By fredsilvester93 in forum Java Theory & Questions
    Replies: 2
    Last Post: July 19th, 2012, 04:01 PM
  2. Why and where abstract methods & classes and static methods are used?
    By ajaysharma in forum Object Oriented Programming
    Replies: 7
    Last Post: July 14th, 2012, 01:16 AM
  3. display methods with inheritance
    By ddotreprah in forum Object Oriented Programming
    Replies: 2
    Last Post: November 20th, 2011, 10:06 PM
  4. inheritance help
    By justin3492 in forum Object Oriented Programming
    Replies: 3
    Last Post: September 30th, 2010, 07:45 PM
  5. inheritance
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 30th, 2010, 09:23 PM