# I need some help with inheritance methods.

• September 26th, 2012, 10:15 AM
13078
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
}
• December 31st, 2012, 11:14 AM
shmob
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!!