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