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
}