I HAVE THE FOLLOWING CODE IN JAVA FOR A SNAKE GAME, I WANT SOMEONE TO EXPLAIN EACH PART OF THE CODE, WHAT'S THE FUNCTION OF EACH PART
THANK YOU
import java.awt.Color;
import java.awt.Graphics;
public class BodyPart {
private int xCoor, yCoor, width, height;
public BodyPart(int xCoor, int yCoor, int tileSize) {
this.xCoor = xCoor;
this.yCoor = yCoor;
width = tileSize;
height = tileSize;
}
public void tick() {
}
public void draw(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(xCoor * width, yCoor * height, width, height);
}
public int getxCoor() {
return xCoor;
}
public void setxCoor(int xCoor) {
this.xCoor = xCoor;
}
public int getyCoor() {
return yCoor;
}
public void setyCoor(int yCoor) {
this.yCoor = yCoor;
}
}
I HAVE THE FOLLOWING CODE IN JAVA FOR A SNAKE GAME, I WANT SOMEONE TO EXPLAIN...
I HAVE THE FOLLOWING CODE IN JAVA FOR A SNAKE GAME, I WANT SOMEONE TO EXPLAIN EACH PART OF THE CODE, WHAT'S THE FUNCTION OF EACH PART THANK YOU import java.awt.Color; import java.awt.Graphics; public class Apple { private int xCoor, yCoor, width, height; public Apple(int xCoor, int yCoor, int tileSize) { this.xCoor = xCoor; this.yCoor = yCoor; width = tileSize; height = tileSize; } public void tick() { } public void draw(Graphics g) { g.setColor(Color.RED); g.fillRect(xCoor * width , yCoor...
Java Program
The goal of this assignment is to develop an event-based game.
You are going to develop a Pong Game.
The game board is a rectangle with a ball bouncing around. On
the right wall, you will have a rectangular paddle (1/3 of the wall
height). The paddle moves with up and down arrows. Next to the game
board, there will be a score board. It will show the count of
goals, and count of hits to the paddle....
please help me to creating UML class diagrams. Snake.java package graphichal2; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Random; enum Dir{L, U, R, D}; class Food { public static int FOODSTYLE = 1; private int m = r.nextInt(Yard.WIDTH / Yard.B_WIDTH); private int n = r.nextInt(Yard.HEIGHT / Yard.B_WIDTH - 30/Yard.B_WIDTH) + 30/Yard.B_WIDTH;// 竖格 public static Random r = new Random(); public int getM() { return m; } public void setM(int m)...
Java question. I am creating a clock program in Java GUI, but it has some problem. First, The time of the clock is not correct. It has to point at the current time. Second, the position of the clock character is wrong. Please fix it for me please. import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.util.Date; import javax.swing.JPanel; import javax.swing.WindowConstants; public class Clock extends javax.swing.JFrame { public int hour; public int min; public int sec; ClockDial cd; public Clock() {...
This is a Clock program in Java. Can you fix my Java program error, and add function to display current time currently? import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.util.Date; import javax.swing.JPanel; import javax.swing.WindowConstants; public class Clock extends javax.swing.JFrame { public int hour; public int min; public int sec; ClockDial cd; public Clock() { setSize(510, 530); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); cd = new ClockDial(this); getContentPane().add(cd); Date curr = new Date(); String time = curr.toString(); hour = Integer.parseInt(time.substring(11, 13)); min = Integer.parseInt(time.substring(14, 16)); sec...
"Polygon Drawer Write an applet that lets the user click on six points. After the sixth point is clicked, the applet should draw a polygon with a vertex at each point the user clicked." import java.awt.*; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import java.applet.*; public class PolygonDrawer extends Applet implements MouseListener{ //Declares variables private int[] X, Y; private int ptCT; private final static Color polygonColor = Color.BLUE; //Color stuff public void init() { setBackground(Color.BLACK); addMouseListener(this); X = new int [450]; Y =...
JAVA JAR HELP...ASAP
I have the code that i need for my game Connect 4, but i need to
create a jar file . the instructions are below. It has to pass some
parameters. I am really confused on doing so.l I dont know what to
do next. Can someone help me and give detailed descritiopm opn how
you ran the jar file in CMD
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Connect4 {
...
(JAVA NetBeans)
Write programs in java
Example 10.21-24
//Animal.java
/** Animal class
* Anderson. Franceschi
*/
import java.awt.Graphics;
public abstract class Animal
{
private int x; // x position
private int y; // y position
private String ID; // animal ID
/** default constructor
* Sets ID to empty String
*/
public Animal( )
{
ID = "";
}
/** Constructor
* @param rID Animal ID
* @param rX x position
* @param rY y position
*/
public Animal( String...
I have to create a java graphics program which will draw 10 rectangles and 10 ellipses on the screen. These shapes are to be stored in an arrayList. I have to do this using 6 different class files. I am not sure whether I successfully created an ellipse in the Oval Class & also need help completing the print Class. I need someone to check whether my Oval Class is correct (it successfully creates an ellipse with x, y, width,...
***This is a JAVA question***
------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;
public class DrawingPanel implements ActionListener {
public static final int DELAY = 50; // delay between repaints in
millis
private static final String DUMP_IMAGE_PROPERTY_NAME =
"drawingpanel.save";
private static String TARGET_IMAGE_FILE_NAME = null;
private static final boolean PRETTY = true; // true to
anti-alias
private static boolean DUMP_IMAGE = true; // true to write
DrawingPanel to file
private int width, height; // dimensions...