All done
This commit is contained in:
parent
27b81ee5a9
commit
baf8f83855
@ -46,9 +46,31 @@ public class DrawningMonorail {
|
|||||||
DrawningWheels = new DrawningWheelsCart(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,wheelColor,tireColor);
|
DrawningWheels = new DrawningWheelsCart(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,wheelColor,tireColor);
|
||||||
else
|
else
|
||||||
DrawningWheels = new DrawningWheelsOrn(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,wheelColor,tireColor);
|
DrawningWheels = new DrawningWheelsOrn(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,wheelColor,tireColor);
|
||||||
DrawningWheels.ChangeWheelsNumb(rand.nextInt(1, 6));
|
DrawningWheels.ChangeWheelsNumb(rand.nextInt(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetIDrawType(){
|
||||||
|
if(DrawningWheels instanceof DrawningWheels)
|
||||||
|
return 0;
|
||||||
|
if(DrawningWheels instanceof DrawningWheelsCart)
|
||||||
|
return 1;
|
||||||
|
if(DrawningWheels instanceof DrawningWheelsOrn)
|
||||||
|
return 2;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeIDraw(int variant){
|
||||||
|
IDraw cur;
|
||||||
|
int dif = _monorailWidth / 10;
|
||||||
|
if(variant == 0)
|
||||||
|
cur = new DrawningWheels(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,Color.GRAY,Color.BLACK);
|
||||||
|
else if(variant == 1)
|
||||||
|
cur = new DrawningWheelsCart(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY, Color.GRAY,Color.BLACK);
|
||||||
|
else
|
||||||
|
cur = new DrawningWheelsOrn(_monorailWidth - dif, _monorailHeight,_startPosX,_startPosY,Color.GRAY, Color.BLACK);
|
||||||
|
ChangeIDraw(cur);
|
||||||
|
|
||||||
|
}
|
||||||
public void ChangeIDraw(IDraw obj){
|
public void ChangeIDraw(IDraw obj){
|
||||||
DrawningWheels = obj;
|
DrawningWheels = obj;
|
||||||
obj.ChangeWheelsNumb(_wheelNumb);
|
obj.ChangeWheelsNumb(_wheelNumb);
|
||||||
|
@ -47,17 +47,23 @@ public class ExtentionDrawningMonorail {
|
|||||||
public static DrawningMonorail CreateDrawningMonorail(String info, char separatorForObject,
|
public static DrawningMonorail CreateDrawningMonorail(String info, char separatorForObject,
|
||||||
int width, int height){
|
int width, int height){
|
||||||
String[] strs = info.split(Character.toString(separatorForObject));
|
String[] strs = info.split(Character.toString(separatorForObject));
|
||||||
if(strs.length == 5){
|
if(strs.length == 7){
|
||||||
return new DrawningMonorail(Integer.parseInt(strs[0]),
|
DrawningMonorail toRet = new DrawningMonorail(Integer.parseInt(strs[0]),
|
||||||
Integer.parseInt(strs[1]), getColor(strs[2]),
|
Integer.parseInt(strs[1]), getColor(strs[2]),
|
||||||
getColor(strs[3]), getColor(strs[4]), width, height);
|
getColor(strs[3]), getColor(strs[4]), width, height);
|
||||||
|
toRet.ChangeWheelsNumb(Integer.parseInt(strs[5]));
|
||||||
|
toRet.ChangeIDraw(Integer.parseInt(strs[6]));
|
||||||
|
return toRet;
|
||||||
}
|
}
|
||||||
if(strs.length == 9){
|
if(strs.length == 10){
|
||||||
return new DrawningLocomotive(Integer.parseInt(strs[0]),
|
DrawningMonorail toRet = new DrawningLocomotive(Integer.parseInt(strs[0]),
|
||||||
Integer.parseInt(strs[1]), getColor(strs[2]),
|
Integer.parseInt(strs[1]), getColor(strs[2]),
|
||||||
getColor(strs[3]), getColor(strs[4]),
|
getColor(strs[3]), getColor(strs[4]),
|
||||||
Integer.parseInt(strs[5]), width, height, Boolean.parseBoolean(strs[6]),
|
4, width, height, Boolean.parseBoolean(strs[7]),
|
||||||
Boolean.parseBoolean(strs[7]), getColor(strs[8]));
|
Boolean.parseBoolean(strs[8]), getColor(strs[9]));
|
||||||
|
toRet.ChangeWheelsNumb(Integer.parseInt(strs[5]));
|
||||||
|
toRet.ChangeIDraw(Integer.parseInt(strs[6]));
|
||||||
|
return toRet;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -66,16 +72,17 @@ public class ExtentionDrawningMonorail {
|
|||||||
if(monorail == null)
|
if(monorail == null)
|
||||||
return null;
|
return null;
|
||||||
String colName = getName(monorail.BodyColor);
|
String colName = getName(monorail.BodyColor);
|
||||||
var str = String.format("%d%c%d%c%s%c%s%c%s", monorail.Speed(), separatorForObject, (int)monorail.Weight(),
|
var str = String.format("%d%c%d%c%s%c%s%c%s%c%d%c%d", monorail.Speed(), separatorForObject, (int)monorail.Weight(),
|
||||||
separatorForObject, getName(monorail.BodyColor), separatorForObject,
|
separatorForObject, getName(monorail.BodyColor), separatorForObject,
|
||||||
getName(monorail.WheelColor), separatorForObject, getName(monorail.TireColor));
|
getName(monorail.WheelColor), separatorForObject, getName(monorail.TireColor), separatorForObject,
|
||||||
|
drawningMonorail._wheelNumb, separatorForObject, drawningMonorail.GetIDrawType());
|
||||||
if(!(monorail instanceof EntityLocomotive)){
|
if(!(monorail instanceof EntityLocomotive)){
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
var nstr = String.format("%s%c%d%c%b%c%b%c%s", str, separatorForObject,
|
var nstr = String.format("%s%c%b%c%b%c%s", str, separatorForObject,
|
||||||
drawningMonorail._wheelNumb, separatorForObject, ((EntityLocomotive) monorail).SecondCabine(), separatorForObject,
|
((EntityLocomotive) monorail).SecondCabine(), separatorForObject,
|
||||||
((EntityLocomotive) monorail).MagniteRail(), separatorForObject,
|
((EntityLocomotive) monorail).MagniteRail(), separatorForObject,
|
||||||
getName(((EntityLocomotive) monorail).AdditionalColor));
|
getName(((EntityLocomotive) monorail).AdditionalColor), separatorForObject);
|
||||||
return nstr;
|
return nstr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,8 @@ public class FormMonorailCollection {
|
|||||||
String collectionName = strs[1];
|
String collectionName = strs[1];
|
||||||
MonorailGenericCollection<DrawningMonorail, DrawningObjectMonorail> collection = new MonorailGenericCollection<>(pictureBoxWidth, pictureBoxHeight);
|
MonorailGenericCollection<DrawningMonorail, DrawningObjectMonorail> collection = new MonorailGenericCollection<>(pictureBoxWidth, pictureBoxHeight);
|
||||||
String[] monorailsInfo = strs[2].split(Character.toString(MonorailGenericCollection._separatorRecords));
|
String[] monorailsInfo = strs[2].split(Character.toString(MonorailGenericCollection._separatorRecords));
|
||||||
for(String data : monorailsInfo){
|
for(int i = monorailsInfo.length-1; i >= 0; i--){
|
||||||
|
String data = monorailsInfo[i];
|
||||||
DrawningMonorail monorail = ExtentionDrawningMonorail.CreateDrawningMonorail(data,
|
DrawningMonorail monorail = ExtentionDrawningMonorail.CreateDrawningMonorail(data,
|
||||||
MonorailGenericCollection._separatorForObject, pictureBoxWidth, pictureBoxHeight);
|
MonorailGenericCollection._separatorForObject, pictureBoxWidth, pictureBoxHeight);
|
||||||
if (monorail != null)
|
if (monorail != null)
|
||||||
@ -156,7 +157,7 @@ public class FormMonorailCollection {
|
|||||||
saveFile.addActionListener(new ActionListener() {
|
saveFile.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser("C:\\Users\\frenk\\OneDrive\\Рабочий стол\\lab6saves");
|
||||||
fc.addChoosableFileFilter(new TxtSaveFilter());
|
fc.addChoosableFileFilter(new TxtSaveFilter());
|
||||||
int retrieval = fc.showSaveDialog(null);
|
int retrieval = fc.showSaveDialog(null);
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ public class FormMonorailCollection {
|
|||||||
saveCollection.addActionListener(new ActionListener() {
|
saveCollection.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser("C:\\Users\\frenk\\OneDrive\\Рабочий стол\\lab6saves");
|
||||||
fc.addChoosableFileFilter(new TxtSaveFilter());
|
fc.addChoosableFileFilter(new TxtSaveFilter());
|
||||||
int retrieval = fc.showSaveDialog(null);
|
int retrieval = fc.showSaveDialog(null);
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ public class FormMonorailCollection {
|
|||||||
loadFile.addActionListener(new ActionListener() {
|
loadFile.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser("C:\\Users\\frenk\\OneDrive\\Рабочий стол\\lab6saves");
|
||||||
int ret = fc.showDialog(null, "Открыть файл");
|
int ret = fc.showDialog(null, "Открыть файл");
|
||||||
if(ret == JFileChooser.APPROVE_OPTION){
|
if(ret == JFileChooser.APPROVE_OPTION){
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
@ -218,7 +219,7 @@ public class FormMonorailCollection {
|
|||||||
loadCollection.addActionListener(new ActionListener() {
|
loadCollection.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser("C:\\Users\\frenk\\OneDrive\\Рабочий стол\\lab6saves");
|
||||||
int ret = fc.showDialog(null, "Открыть файл");
|
int ret = fc.showDialog(null, "Открыть файл");
|
||||||
if(ret == JFileChooser.APPROVE_OPTION){
|
if(ret == JFileChooser.APPROVE_OPTION){
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
|
@ -362,7 +362,6 @@ public class FormMonorailConfig {
|
|||||||
String data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
|
String data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case "Простой":
|
case "Простой":
|
||||||
|
|
||||||
_monorail = new DrawningMonorail(speed, weight, Color.WHITE,
|
_monorail = new DrawningMonorail(speed, weight, Color.WHITE,
|
||||||
Color.GRAY, Color.BLACK, _pictureBoxWidth, _pictureBoxHeight);
|
Color.GRAY, Color.BLACK, _pictureBoxWidth, _pictureBoxHeight);
|
||||||
_monorail.ChangeWheelsNumb(wheelNumb);
|
_monorail.ChangeWheelsNumb(wheelNumb);
|
||||||
|
@ -61,7 +61,9 @@ public class MonorailGenericStorage {
|
|||||||
MonorailGenericCollection<DrawningMonorail, DrawningObjectMonorail> collection =
|
MonorailGenericCollection<DrawningMonorail, DrawningObjectMonorail> collection =
|
||||||
new MonorailGenericCollection<>(_pictureWidth, _pictureHeight);
|
new MonorailGenericCollection<>(_pictureWidth, _pictureHeight);
|
||||||
String[] set = record[1].split(Character.toString(_separatorRecords));
|
String[] set = record[1].split(Character.toString(_separatorRecords));
|
||||||
for(String elem : set){
|
|
||||||
|
for(int i = set.length -1; i >=0; i--){
|
||||||
|
String elem = set[i];
|
||||||
DrawningMonorail monorail = ExtentionDrawningMonorail.CreateDrawningMonorail(elem,
|
DrawningMonorail monorail = ExtentionDrawningMonorail.CreateDrawningMonorail(elem,
|
||||||
_separatorForObject, _pictureWidth, _pictureHeight);
|
_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
if (monorail != null)
|
if (monorail != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user