Первая лабораторная работа. Усложненная. С дополнительным заданием и исправлениями.
This commit is contained in:
parent
143fc0e022
commit
72a1782e61
@ -3,11 +3,11 @@ public enum BlockCount {
|
||||
FourBlocks(4),
|
||||
SixBlocks(6);
|
||||
|
||||
private final int value;
|
||||
private final int Value;
|
||||
BlockCount(int count){
|
||||
value=count;
|
||||
Value=count;
|
||||
}
|
||||
public int GetBlockCount(){
|
||||
return value;
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@ import java.awt.*;
|
||||
|
||||
public class DrawingBlock {
|
||||
|
||||
private BlockCount _Block;
|
||||
private BlockCount _block;
|
||||
|
||||
public void SetBlockCount(int count){
|
||||
for (BlockCount temp: BlockCount.values())
|
||||
if (temp.GetBlockCount() == count){
|
||||
_Block=temp;
|
||||
_block=temp;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawBlock(Graphics2D g,int _startPosX, int _startPosY) {
|
||||
if (_Block.GetBlockCount() >= 2) {
|
||||
if (_block.GetBlockCount() >= 2) {
|
||||
g.setColor(Color.GRAY);
|
||||
g.fillRect(_startPosX + 25, _startPosY + 10, 10, 10);
|
||||
g.setColor(Color.BLACK);
|
||||
@ -23,7 +23,7 @@ public class DrawingBlock {
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_startPosX + 25, _startPosY + 20, 10, 10);
|
||||
}
|
||||
if (_Block.GetBlockCount() >= 4) {
|
||||
if (_block.GetBlockCount() >= 4) {
|
||||
g.setColor(Color.GRAY);
|
||||
g.fillRect(_startPosX+35,_startPosY+10,10,10);
|
||||
g.setColor(Color.BLACK);
|
||||
@ -33,7 +33,7 @@ public class DrawingBlock {
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_startPosX+35,_startPosY+20,10,10);
|
||||
}
|
||||
if (_Block.GetBlockCount() >= 6) {
|
||||
if (_block.GetBlockCount() >= 6) {
|
||||
g.setColor(Color.GRAY);
|
||||
g.fillRect(_startPosX+45,_startPosY+10,10,10);
|
||||
g.setColor(Color.BLACK);
|
||||
|
@ -3,10 +3,10 @@ import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingField extends JPanel {
|
||||
private final FormWarship field;
|
||||
private final FormWarship Field;
|
||||
DrawingWarship _warship;
|
||||
public DrawingField(FormWarship field) {
|
||||
this.field = field;
|
||||
this.Field = field;
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
@ -45,9 +45,9 @@ public class DrawingField extends JPanel {
|
||||
_warship=new DrawingWarship();
|
||||
_warship.Init(rand.nextInt(50)+10,rand.nextInt(3000)+20000,new Color(rand.nextInt(256),rand.nextInt(256),rand.nextInt(256)));
|
||||
_warship.SetPosition(rand.nextInt(100)+10,rand.nextInt(100)+10,getWidth(),getHeight());
|
||||
field.SpeedLabel.setText("Скорость: "+_warship.GetWarship().GetSpeed());
|
||||
field.WeightLabel.setText("Вес: "+_warship.GetWarship().GetWeight());
|
||||
field.BodyColorLabel.setText("Цвет: "+Integer.toHexString(_warship.GetWarship().GetBodyColor().getRGB()).substring(2));
|
||||
Field.SpeedLabel.setText("Скорость: "+_warship.GetWarship().GetSpeed());
|
||||
Field.WeightLabel.setText("Вес: "+_warship.GetWarship().GetWeight());
|
||||
Field.BodyColorLabel.setText("Цвет: "+Integer.toHexString(_warship.GetWarship().GetBodyColor().getRGB()).substring(2));
|
||||
}
|
||||
public void ResizeField(){
|
||||
if (_warship!=null)
|
||||
|
Loading…
Reference in New Issue
Block a user