Начало
This commit is contained in:
parent
8737449c24
commit
5bb5a8e93e
@ -1,3 +1,4 @@
|
||||
package Directions;
|
||||
public enum CountWheels{
|
||||
Min(2),
|
||||
Mid(3),
|
||||
@ -10,7 +11,7 @@ public enum CountWheels{
|
||||
public int getCountWheels(){
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
public static CountWheels fromNumberToEnum(int number) {
|
||||
try{
|
||||
for (CountWheels countWheels : CountWheels.values()) {
|
@ -1,3 +1,4 @@
|
||||
package Directions;
|
||||
|
||||
enum Direction{
|
||||
UP(1),
|
||||
@ -8,4 +9,7 @@ enum Direction{
|
||||
private Direction(int val){
|
||||
this.val = val;
|
||||
}
|
||||
public int getDirection(){
|
||||
return val;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import Directions.CountWheels;
|
||||
public class DrawingWheels{
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
|
@ -1,10 +1,15 @@
|
||||
package DrawningObjects;
|
||||
import java.awt.*;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import Directions.Direction;
|
||||
import Entities.EntityMonorail;
|
||||
|
||||
import java.util.Random;
|
||||
import java.lang.*;
|
||||
|
||||
public class DrawningMonorail extends JPanel {
|
||||
private Entity entity;
|
||||
private EntityMonorail entity;
|
||||
private int pictureWidth;
|
||||
private int pictureHeight;
|
||||
private int _countWheels;
|
||||
@ -23,7 +28,7 @@ public class DrawningMonorail extends JPanel {
|
||||
_countWheels = wheelCount;
|
||||
pictureWidth = width;
|
||||
pictureHeight = height;
|
||||
entity = new Entity();
|
||||
entity = new EntityMonorail();
|
||||
entity.init(wheelCount, speed, weight, bodyColor, additionalColor, monorails, secondCabin);
|
||||
return true;
|
||||
}
|
@ -1,25 +1,21 @@
|
||||
package Entities;
|
||||
import java.awt.*;
|
||||
|
||||
public class Entity {
|
||||
public class EntityMonorail {
|
||||
private int speed;
|
||||
private int wheelCount;
|
||||
private double weight;
|
||||
private Color bodyColor;
|
||||
private Color additionalColor;
|
||||
private boolean monorails;
|
||||
private boolean secondCabin;
|
||||
|
||||
|
||||
public double getStep() {
|
||||
return (double) speed * 130 / weight;
|
||||
}
|
||||
|
||||
public void init(int wheelCount, int speed, double weight, Color bodyColor, Color additionalColor, boolean monorails, boolean secondCabin) {
|
||||
public void init(int wheelCount, int speed, double weight, Color bodyColor) {
|
||||
setSpeed(speed);
|
||||
setWeight(weight);
|
||||
setBodyColor(bodyColor);
|
||||
setAdditionalColor(additionalColor);
|
||||
setMonorails(monorails);
|
||||
setSecondCabin(secondCabin);
|
||||
setWheelCount(wheelCount);
|
||||
}
|
||||
|
||||
@ -47,29 +43,6 @@ public class Entity {
|
||||
this.bodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public Color getAdditionalColor() {
|
||||
return additionalColor;
|
||||
}
|
||||
|
||||
private void setAdditionalColor(Color additionalColor) {
|
||||
this.additionalColor = additionalColor;
|
||||
}
|
||||
|
||||
public boolean getMonorails() {
|
||||
return monorails;
|
||||
}
|
||||
|
||||
private void setMonorails(boolean monorails) {
|
||||
this.monorails = monorails;
|
||||
}
|
||||
|
||||
public boolean getSecondCabin() {
|
||||
return secondCabin;
|
||||
}
|
||||
|
||||
private void setSecondCabin(boolean secondCabin) {
|
||||
this.secondCabin = secondCabin;
|
||||
}
|
||||
public int getWheelCount(){
|
||||
return wheelCount;
|
||||
}
|
37
Entities/EntitySecondMonorail.java
Normal file
37
Entities/EntitySecondMonorail.java
Normal file
@ -0,0 +1,37 @@
|
||||
package Entities;
|
||||
import java.awt.*;
|
||||
|
||||
public class EntitySecondMonorail {
|
||||
private Color additionalColor;
|
||||
private boolean monorails;
|
||||
private boolean secondCabin;
|
||||
public EntitySecondMonorail(Color additionalColor, boolean monorails, boolean secondCabin){
|
||||
setAdditionalColor(additionalColor);
|
||||
setMonorails(monorails);
|
||||
setSecondCabin(secondCabin);
|
||||
}
|
||||
|
||||
public Color getAdditionalColor() {
|
||||
return additionalColor;
|
||||
}
|
||||
|
||||
private void setAdditionalColor(Color additionalColor) {
|
||||
this.additionalColor = additionalColor;
|
||||
}
|
||||
|
||||
public boolean getMonorails() {
|
||||
return monorails;
|
||||
}
|
||||
|
||||
private void setMonorails(boolean monorails) {
|
||||
this.monorails = monorails;
|
||||
}
|
||||
|
||||
public boolean getSecondCabin() {
|
||||
return secondCabin;
|
||||
}
|
||||
|
||||
private void setSecondCabin(boolean secondCabin) {
|
||||
this.secondCabin = secondCabin;
|
||||
}
|
||||
}
|
@ -3,6 +3,10 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.*;
|
||||
|
||||
import Directions.Direction;
|
||||
import DrawningObjects.DrawningMonorail;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
class Form extends JFrame{
|
||||
|
Loading…
x
Reference in New Issue
Block a user