Restore
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question1</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
import java.awt.Graphics;
|
||||
|
||||
public interface IShape {
|
||||
public int getX();
|
||||
public int getY();
|
||||
public void setX(int x);
|
||||
public void setY(int y);
|
||||
public boolean isVisible(int w, int h);
|
||||
public boolean isIn(int x, int y);
|
||||
public void draw(Graphics g);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
public abstract class Shape implements IShape{
|
||||
//instance variables
|
||||
private int x;
|
||||
private int y;
|
||||
private Color color;
|
||||
|
||||
//constructor
|
||||
public Shape(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.color = new Color( (float)Math.random(),
|
||||
(float)Math.random(),
|
||||
(float)Math.random() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isVisible(int w, int h);
|
||||
|
||||
@Override
|
||||
public abstract boolean isIn(int x, int y);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
g.setColor(color);
|
||||
}
|
||||
|
||||
public static void testShape() {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Start {
|
||||
public static void main(String[] args) {
|
||||
Shape.testShape();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user