I have to write a code that displays a 4 x 4 grid of faces. I am stuck and this is wat i have so far:
import java.awt.Graphics;
import java.util.Scanner;
import javax.swing.JApplet;
public class Program7 extends JApplet {
public void init() {
setSize(2000, 2000);
}
/**
* Draw one happy face at position (xOffset,yOffset) rather
* than at (0,0)
*/
public void happyFace(int xOffset, int yOffset, Graphics canvas) {
// Put your code here
canvas.drawOval(100, 50, 200, 200);
canvas.fillOval(155, 100, 20, 30);
canvas.fillOval(230, 100, 20, 30);
canvas.drawOval(150, 175, 100, 50);
canvas.fillOval(150, 175, 100, 50);
canvas.drawOval(195, 140, 10, 20);
canvas.fillOval(195, 140, 10, 20);
canvas.drawLine(150, 65, 80, 10);
canvas.drawLine(150, 65, 100, 10);
canvas.drawLine(150, 65, 90, 10);
canvas.drawLine(150, 65, 110, 10);
canvas.drawLine(150, 65, 120, 10);
canvas.drawLine(150, 65, 130, 10);
canvas.drawLine(150, 65, 140, 10);
canvas.drawLine(150, 65, 150, 10);
canvas.drawLine(150, 65, 160, 10);
canvas.drawLine(150, 65, 170, 10);
canvas.drawLine(150, 65, 180, 10);
canvas.drawLine(150, 65, 190, 10);
canvas.drawLine(150, 65, 200, 10);
canvas.drawLine(150, 65, 210, 10);
canvas.drawLine(150, 65, 220, 10);
canvas.drawLine(150, 65, 230, 10);
canvas.drawLine(150, 65, 240, 10);
canvas.drawLine(150, 65, 250, 10);
}
/**
* return true if value is an odd number, otherwise return false
*/
public boolean isOdd(int value) {
// Put your code here
}
public void paint(Graphics canvas) {
// Put your code here
}
/**
* Draw one sad face at position (xOffset,yOffset) rather
* than at (0,0)
*/
public void sadFace(int xOffset, int yOffset, Graphics canvas) {
// Put your code here
canvas.drawOval(100, 50, 200, 200);
canvas.fillOval(155, 100, 20, 30);
canvas.fillOval(230, 100, 20, 30);
canvas.drawOval(150, 175, 100, 50);
canvas.fillOval(150, 175, 100, 50);
canvas.drawOval(195, 140, 10, 20);
canvas.fillOval(195, 140, 10, 20);
canvas.drawLine(150, 65, 80, 10);
canvas.drawLine(150, 65, 100, 10);
canvas.drawLine(150, 65, 90, 10);
canvas.drawLine(150, 65, 110, 10);
canvas.drawLine(150, 65, 120, 10);
canvas.drawLine(150, 65, 130, 10);
canvas.drawLine(150, 65, 140, 10);
canvas.drawLine(150, 65, 150, 10);
canvas.drawLine(150, 65, 160, 10);
canvas.drawLine(150, 65, 170, 10);
canvas.drawLine(150, 65, 180, 10);
canvas.drawLine(150, 65, 190, 10);
canvas.drawLine(150, 65, 200, 10);
canvas.drawLine(150, 65, 210, 10);
canvas.drawLine(150, 65, 220, 10);
canvas.drawLine(150, 65, 230, 10);
canvas.drawLine(150, 65, 240, 10);
canvas.drawLine(150, 65, 250, 10);
}
}