A "the function display () does not exist" in reference to a subclass that has a display method???
              in 
             Programming Questions 
              •  
              1 years ago    
            
 
           
             I am getting a "the function display () does not exist" for my quiltpatterns tiles even though there is a display function in that subclass. What am I not getting?
            
            
            
            
PFont fontInstructions; // create a variable to load the font
            
PImage [] quiltPatterns = new PImage [4]; // declare a variable that stores an array of quilting patterns images from clip art
            
EmptyGrid myEmptyGrid;
            
            
void setup() { // call the setup function to define initial enviroment properties
            
size(900, 700); // set the canvas size at 800 pixels by 800 pixels
background(230); // set background color to light gray
            
fontInstructions=loadFont("CurlzMT-48.vlw"); // load the font used for the text in a data file attached to this file
textFont (fontInstructions); // set the loaded font as the current one to use
            
for (int q = 0; q < quiltPatterns.length; q++) { // create an array that loads the array of quilt patterns as numbered files
quiltPatterns[q] = loadImage("pattern" + (q+1) + ".gif"); // load each quilt pattern individually based on its numbered file
} // end the for loop for loading the array of quilt patterns as numbered files
            
myEmptyGrid= new EmptyGrid (color(227, 208, 140), 100);
} // end the setup function
            
void draw () { // call the draw function
            
background(230); // reset background color to light gray everytime the draw function is recalled
            
for (int q = 0; q < quiltPatterns.length; q++) { // create an array that loads the array of quilt patterns as numbered files
quiltPatterns[q].display();
} // end the for loop for loading the array of quilt patterns as numbered files
            
            
myEmptyGrid.display();
  
            
} // end the draw function
            
            
            
abstract class Grid {
            
            
float sizeOfSquares;
color gridClr;
            
            
Grid(color tempgridClr, float tempsizeOfSquares) {
            
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
} // end of the constructor
            
            
            
void display () {
            
// initialization of quilt patterns (from Shiffman page 261)
            
for (int i=0;i<width;i+=sizeOfSquares) {
for (int j=0;j<height;j+=sizeOfSquares) {
fill(gridClr);
rect(i, j, sizeOfSquares, sizeOfSquares);
}
}
} // end of the display function
}
            
            
class EmptyGrid extends Grid {
            
            
EmptyGrid(color tempgridClr, float tempsizeOfSquares) {
    
            
super (tempgridClr, tempsizeOfSquares);
        
            
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
    
            
} // end of the constructor
            
  
            
void display () {
            
// initialization of quilt patterns (from Shiffman page 261)
            
for (int i=200;i<width;i+=sizeOfSquares) {
for (int j=100;j<height;j+=sizeOfSquares) {
fill(gridClr);
rect(i, j, sizeOfSquares, sizeOfSquares);
}
}
} // end of the display function
} // end of the Grid class
            
            
class Patterns extends Grid {
            
            
EmptyGrid(color tempgridClr, float tempsizeOfSquares) {
            
super (tempgridClr, tempsizeOfSquares);
            
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
} // end of the constructor
            
void display() {
            
image (quiltPatterns[0], 0, height-600, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[1], 0, height-450, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[2], 0, height-300, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[3], 0, height-150, sizeOfSquares, sizeOfSquares);
}
}
            
            
// code for the instructions class
            
class Instructions { // create a class for the instructions
            
// fields
            
String instruction1; // create a variable for the first line of the instructions that will appear on the screen
String instruction2; // create a variable for the second line of the instructions that will appear on the screen
String instruction3; // create a variable for the third line of the instructions that will appear on the screen
String instruction4; // create a variable for the fourth line of the instructions that will appear on the screen
String instruction5; // create a variable for the fifth line of the instructions that will appear on the screen
            
int textX; // create a variable for the X position of the text
int textY; // create a variable for the Y position of the text
            
} // end the intructions class
            
            
            
            
            
            
            
            
            
            
            
 
           
 
            
           PFont fontInstructions; // create a variable to load the font
PImage [] quiltPatterns = new PImage [4]; // declare a variable that stores an array of quilting patterns images from clip art
EmptyGrid myEmptyGrid;
void setup() { // call the setup function to define initial enviroment properties
size(900, 700); // set the canvas size at 800 pixels by 800 pixels
background(230); // set background color to light gray
fontInstructions=loadFont("CurlzMT-48.vlw"); // load the font used for the text in a data file attached to this file
textFont (fontInstructions); // set the loaded font as the current one to use
for (int q = 0; q < quiltPatterns.length; q++) { // create an array that loads the array of quilt patterns as numbered files
quiltPatterns[q] = loadImage("pattern" + (q+1) + ".gif"); // load each quilt pattern individually based on its numbered file
} // end the for loop for loading the array of quilt patterns as numbered files
myEmptyGrid= new EmptyGrid (color(227, 208, 140), 100);
} // end the setup function
void draw () { // call the draw function
background(230); // reset background color to light gray everytime the draw function is recalled
for (int q = 0; q < quiltPatterns.length; q++) { // create an array that loads the array of quilt patterns as numbered files
quiltPatterns[q].display();
} // end the for loop for loading the array of quilt patterns as numbered files
myEmptyGrid.display();
} // end the draw function
abstract class Grid {
float sizeOfSquares;
color gridClr;
Grid(color tempgridClr, float tempsizeOfSquares) {
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
} // end of the constructor
void display () {
// initialization of quilt patterns (from Shiffman page 261)
for (int i=0;i<width;i+=sizeOfSquares) {
for (int j=0;j<height;j+=sizeOfSquares) {
fill(gridClr);
rect(i, j, sizeOfSquares, sizeOfSquares);
}
}
} // end of the display function
}
class EmptyGrid extends Grid {
EmptyGrid(color tempgridClr, float tempsizeOfSquares) {
super (tempgridClr, tempsizeOfSquares);
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
} // end of the constructor
void display () {
// initialization of quilt patterns (from Shiffman page 261)
for (int i=200;i<width;i+=sizeOfSquares) {
for (int j=100;j<height;j+=sizeOfSquares) {
fill(gridClr);
rect(i, j, sizeOfSquares, sizeOfSquares);
}
}
} // end of the display function
} // end of the Grid class
class Patterns extends Grid {
EmptyGrid(color tempgridClr, float tempsizeOfSquares) {
super (tempgridClr, tempsizeOfSquares);
gridClr=tempgridClr;
sizeOfSquares=tempsizeOfSquares;
} // end of the constructor
void display() {
image (quiltPatterns[0], 0, height-600, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[1], 0, height-450, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[2], 0, height-300, sizeOfSquares, sizeOfSquares);
image (quiltPatterns[3], 0, height-150, sizeOfSquares, sizeOfSquares);
}
}
// code for the instructions class
class Instructions { // create a class for the instructions
// fields
String instruction1; // create a variable for the first line of the instructions that will appear on the screen
String instruction2; // create a variable for the second line of the instructions that will appear on the screen
String instruction3; // create a variable for the third line of the instructions that will appear on the screen
String instruction4; // create a variable for the fourth line of the instructions that will appear on the screen
String instruction5; // create a variable for the fifth line of the instructions that will appear on the screen
int textX; // create a variable for the X position of the text
int textY; // create a variable for the Y position of the text
} // end the intructions class
 
              
              1  
            
 
            