Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

There is a syntax error in passing "Graphics g" to the subclas

$
0
0
Could someone help me with debugging this Java applet that exhibits inheritance?

I can finish the rest once i can build this.

Here is the program I have so far:
// This program should create a poorly drawn nyan cat (=^_^/>=)[]/
// However I cannot start plugging in numbers until I discove the correct syntax

import java.awt.*;
import java.applet.*;


public class GraphicsLab04st extends Applet	//main class
{
public void paint(Graphics g)
{
CatMath one = new CatMath(g,55); // place holdr number!!!!!!!!!!!!!!!!

}
}


class Cat	//super class
{
private Color catColor;

public Cat(Graphics g, Color cc, int x)	// constructor
{

catColor = cc;	 // set cat color
g.setColor(catColor);
// cat body

g.fillOval(75,275,100,100); // Head
g.fillRect(x+5,325,50,50);	// Ears
g.fillRect(x+95,325,50,50);	// Body
g.fillRect(x+95,325,50,50);	// Legf1
g.fillRect(x+95,325,50,50);	// Legf2
g.fillRect(x+95,325,50,50);	// Legb1
g.fillRect(x+95,325,50,50);	// Legb2
//tail
Polygon tail = new Polygon();
tail.addPoint(400,70);//base
tail.addPoint(550,200);
tail.addPoint(500,350);//top
tail.addPoint(300,350);

g.drawPolygon(tail);
// rounded edgdes
g.fillOval(75,275,100,100); // paw1
g.fillOval(75,275,100,100);	// paw2
g.fillOval(75,275,100,100);	// paw3
g.fillOval(75,275,100,100);	// paw4
g.fillOval(75,275,100,100);	//tail roundness


}

class NyanCat extends Cat	// subclass
{
private int x;

public NyanCat (Graphics g, Color cc) // constructor
{
super(g,Color cc,int x1);
x = x1;
Poptart(g);
Rainbow(g);
}

public void Poptart (Graphics g)
{
g.fillRect(x+95,325,50,50);//base
g.fillRect(x+95,325,50,50);// frosting

int count = 0;
while (count <	24 )
{
g.fillOval(75,275,100,100); // sprinkles top
g.fillOval(75,275,100,100);	// sprinkles bottom
count++;
}
}

public void Rainbow (Graphics g)
{
g.setColor(Color.red);	 //
g.fillRect(x+95,325,50,50);	// r
g.setColor(Color.orange);	 //
g.fillRect(x+95,325,50,50);	// o
g.setColor(Color.yellow);	 //
g.fillRect(x+95,325,50,50);	// y
g.setColor(Color.green);	 //
g.fillRect(x+95,325,50,50);	// g
g.setColor(Color.blue);	 // b
g.fillRect(x+95,325,50,50);	//
g.setColor(Color.MAGENTA);	// v
g.fillRect(x+95,325,50,50);	//


}
}
}

class Mathmatics
{
public Plus (Graphics g)
{
g.setColor(Color.red);
g.fillRect(x+95,325,50,50);	// plus sign
g.fillRect(x+95,325,50,50);	//
}

public Equals (Graphics g)
{
g.setColor(Color.red);
g.fillRect(x+95,325,50,50);	// equal sign
g.fillRect(x+95,325,50,50);	//
}

}
class CatMath
{


public Train(Graphics g, int x)
{

Cat random = new Cat(g,Color.orange,x+200);	 // place holder numbers!!!!!!!!!!
NyanCat awesome = new NyanCat(g,Color.grey,x+500); // place holder numbers!!!!!!!!!!
Mathmatics signs = new Mathmatics(g);
}




}



}

}





//

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>