Complete lab
This commit is contained in:
parent
0c7b7b773c
commit
0f832390b4
@ -1,15 +1,15 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawningIlluminator extends JComponent {
|
||||
public class DrawningIlluminator implements IDrawningIlluminator{
|
||||
private IlluminatorCount _Illuminator;
|
||||
|
||||
@Override
|
||||
public void SetIlluminatorCount(int numOfIllum) {
|
||||
_Illuminator = IlluminatorCount.GetIlluminatorCount(numOfIllum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawIlluminator(Graphics g, int _startPosX, int _startPosY) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Color.BLACK);
|
||||
int numOfIlluminator = 0;
|
||||
|
@ -13,7 +13,7 @@ public class DrawningPlane extends JPanel {
|
||||
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
public DrawningIlluminator IlluminatorDraw;
|
||||
public IDrawningIlluminator IlluminatorDraw;
|
||||
public Integer _pictureWidth = null;
|
||||
public Integer _pictureHeight = null;
|
||||
private int _PlaneWidth = 130;
|
||||
@ -29,7 +29,18 @@ public class DrawningPlane extends JPanel {
|
||||
public DrawningPlane(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Plane = new EntityPlane(speed, weight, bodyColor);
|
||||
IlluminatorDraw = new DrawningIlluminator();
|
||||
Random random = new Random();
|
||||
switch (random.nextInt(3)){
|
||||
case 0:
|
||||
IlluminatorDraw = new DrawningIlluminator();
|
||||
break;
|
||||
case 1:
|
||||
IlluminatorDraw = new DrawningSqareIlluminator();
|
||||
break;
|
||||
case 2:
|
||||
IlluminatorDraw = new DrawningTriangleIlluminator();
|
||||
break;
|
||||
}
|
||||
SetIlluminator();
|
||||
}
|
||||
|
||||
|
33
DrawningSqareIlluminator.java
Normal file
33
DrawningSqareIlluminator.java
Normal file
@ -0,0 +1,33 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawningSqareIlluminator implements IDrawningIlluminator{
|
||||
private IlluminatorCount _Illuminator;
|
||||
@Override
|
||||
public void SetIlluminatorCount(int numOfIllum) {_Illuminator = IlluminatorCount.GetIlluminatorCount(numOfIllum); }
|
||||
|
||||
@Override
|
||||
public void DrawIlluminator(Graphics g, int _startPosX, int _startPosY) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Color.BLACK);
|
||||
int numOfIlluminator = 0;
|
||||
switch (_Illuminator)
|
||||
{
|
||||
case Ten:
|
||||
numOfIlluminator = 10;
|
||||
break;
|
||||
case Twenty:
|
||||
numOfIlluminator = 20;
|
||||
break;
|
||||
case Thirty:
|
||||
numOfIlluminator = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int i = numOfIlluminator; i >= 1; --i){
|
||||
g2d.setColor(Color.CYAN);
|
||||
g2d.fillRect(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
|
||||
}
|
||||
}
|
||||
}
|
36
DrawningTriangleIlluminator.java
Normal file
36
DrawningTriangleIlluminator.java
Normal file
@ -0,0 +1,36 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawningTriangleIlluminator implements IDrawningIlluminator{
|
||||
private IlluminatorCount _Illuminator;
|
||||
|
||||
@Override
|
||||
public void SetIlluminatorCount(int numOfIllum) {
|
||||
_Illuminator = IlluminatorCount.GetIlluminatorCount(numOfIllum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawIlluminator(Graphics g, int _startPosX, int _startPosY) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Color.BLACK);
|
||||
int numOfIlluminator = 0;
|
||||
switch (_Illuminator)
|
||||
{
|
||||
case Ten:
|
||||
numOfIlluminator = 10;
|
||||
break;
|
||||
case Twenty:
|
||||
numOfIlluminator = 20;
|
||||
break;
|
||||
case Thirty:
|
||||
numOfIlluminator = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int i = numOfIlluminator; i >= 1; --i){
|
||||
g2d.setColor(Color.CYAN);
|
||||
g2d.drawPolygon(new int[] {_startPosX + 105 - 3 * i, _startPosX + 102 - 3 * i, _startPosX + 108 - 3 * i}, new int[] {_startPosY + 35, _startPosY + 38, _startPosY + 38}, 3);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillPolygon(new int[] {_startPosX + 105 - 3 * i, _startPosX + 102 - 3 * i, _startPosX + 108 - 3 * i}, new int[] {_startPosY + 35, _startPosY + 38, _startPosY + 38}, 3);
|
||||
}
|
||||
}
|
||||
}
|
7
IDrawningIlluminator.java
Normal file
7
IDrawningIlluminator.java
Normal file
@ -0,0 +1,7 @@
|
||||
import java.awt.*;
|
||||
|
||||
public interface IDrawningIlluminator {
|
||||
|
||||
void SetIlluminatorCount(int numOfIllum);
|
||||
void DrawIlluminator(Graphics g, int _startPosX, int _startPosY);
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import java.awt.*;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public interface IDrawningObject {
|
||||
float Step();
|
||||
|
Loading…
Reference in New Issue
Block a user