This commit is contained in:
root 2022-10-24 21:53:38 +04:00
parent 891fd20505
commit 27ca6d0a4a
39 changed files with 153 additions and 1117 deletions

438
.gitignore vendored
View File

@ -1,400 +1,38 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

7
.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

13
.idea/misc.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

BIN
.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

2
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

View File

@ -4,27 +4,49 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
<list default="true" id="3d7ff202-9cad-4078-bd8f-498ca8bb863e" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/../.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/../.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../PIbd-22_Kalyshev_Y_V_MotorBoat_Hard.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/Direction.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/EntityBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/FormBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/HelloController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/NumberOars.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/module-info.java" beforeDir="false" afterPath="$PROJECT_DIR$/../src/main/java/module-info.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowDown.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowLeft.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowRight.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowUp.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/hello-view.fxml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowDown.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowLeft.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowRight.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowUp.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/Direction.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat$1.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars$1.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/EntityBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/FormBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/HelloController.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/NumberOars.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/hello-view.fxml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/module-info.class" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2GZGMEhxNuxaGk45kFR2jtFs8iE" />
<component name="ProjectId" id="2GajoRqizwxNpAzsDBkYvL8dopf" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
@ -34,18 +56,17 @@
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH": "590"
"SHARE_PROJECT_CONFIGURATION_FILES": "true"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
<created>1666588645694</created>
<changelist id="3d7ff202-9cad-4078-bd8f-498ca8bb863e" name="Changes" comment="" />
<created>1666633764627</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1666588645694</updated>
<updated>1666633764627</updated>
</task>
<servers />
</component>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<groupId>com.zyzf</groupId>
<artifactId>PIbd-22_Kalyshev_Y_V_MotorBoat_Hard</artifactId>
<version>1.0-SNAPSHOT</version>
<name>PIbd-22_Kalyshev_Y_V_MotorBoat_Hard</name>
@ -76,7 +76,7 @@
<id>default-cli</id>
<configuration>
<mainClass>
com.example.pibd22_kalyshev_y_v_motorboat_hard/com.example.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
com.zyzf.pibd22_kalyshev_y_v_motorboat_hard/com.zyzf.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>

View File

@ -1,26 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
public enum Direction {
Up,
Down,
Left,
Right;
public static Direction FromInteger(int intValue)
{
switch(intValue)
{
case 1:
return Up;
case 2:
return Down;
case 3:
return Left;
case 4:
return Right;
default:
System.out.println("Error: incorrect value for enum");
return Up;
}
}
}

View File

@ -1,165 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningBoat
{
private EntityBoat _boat;
private DrawningOars _drawningOars;
private float _startPosX;
private float _startPosY;
private Integer _pictureWidth;
private Integer _pictureHeight;
private int _boatWidth = 112;
private int _boatHeight = 60;
public EntityBoat GetArmoredVehicle()
{
return _boat;
}
public DrawningOars GetDrawningOars()
{
return _drawningOars;
}
public void Init(int speed, float weight, Color bodyColor)
{
_boat = new EntityBoat();
_boat.Init(speed, weight, bodyColor);
_drawningOars = new DrawningOars();
_drawningOars.Init(bodyColor);
}
public void SetPosition(int x, int y, int width, int height)
{
if (x < 0 || y < 0)
{
return;
}
if (x + _boatWidth > width || y + _boatHeight > height)
{
return;
}
_startPosX = x;
_startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
public void MoveTransport(Direction direction)
{
if (_pictureWidth == null || _pictureHeight == null)
{
return;
}
switch (direction)
{
case Up:
if (_startPosY - _boat.GetStep() > 0)
{
_startPosY -= _boat.GetStep();
}
break;
case Down:
if (_startPosY + _boatHeight + _boat.GetStep() < _pictureHeight)
{
_startPosY += _boat.GetStep();
}
break;
case Left:
if (_startPosX - _boat.GetStep() > 0)
{
_startPosX -= _boat.GetStep();
}
break;
case Right:
if (_startPosX + _boatWidth + _boat.GetStep() < _pictureWidth)
{
_startPosX += _boat.GetStep();
}
break;
default:
break;
}
}
public void DrawTransport(GraphicsContext gc)
{
if (_startPosX < 0 || _startPosY < 0
|| _pictureWidth == null || _pictureHeight == null)
{
return;
}
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
// Гусеница
gc.setFill(Color.rgb(21, 39, 71));
gc.fillRect(14.0 + _startPosX, 32.0 + _startPosY, 84.0, 26.0);
gc.strokeRect(14.0 + _startPosX, 32.0 + _startPosY, 84.0, 26.0);
gc.fillOval(1.0 + _startPosX, 32.0 + _startPosY, 26.0, 26.0);
gc.strokeOval(1.0 + _startPosX, 32.0 + _startPosY, 26.0, 26.0);
gc.fillOval(85.0 + _startPosX, 32.0 + _startPosY, 26.0, 26.0);
gc.strokeOval(85.0 + _startPosX, 32.0 + _startPosY, 26.0, 26.0);
gc.fillRect(13.0 + _startPosX, 33.0 + _startPosY, 86.0, 24.0);
// Корпус
gc.setFill(_boat.GetBodyColor());
double[] hullX =
{
23.0 + _startPosX, 23.0 + _startPosX,
37.0 + _startPosX, 75.0+ _startPosX,
89.0 + _startPosX, 89.0 + _startPosX
};
double[] hullY =
{
25.0 + _startPosY, 11.0 + _startPosY,
1.0 + _startPosY, 1.0 + _startPosY,
11.0 + _startPosY, 25.0 + _startPosY
};
gc.fillPolygon(hullX, hullY, 6);
gc.strokePolygon(hullX, hullY, 6);
gc.fillRect(16.0 + _startPosX, 24.0 + _startPosY, 80.0, 8.0);
gc.strokeRect(16.0 + _startPosX, 24.0 + _startPosY, 80.0, 8.0);
_drawningOars.DrawOars(gc, _startPosX, _startPosY);
}
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _boatWidth || _pictureHeight <= _boatHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _boatWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _boatWidth;
}
if (_startPosY + _boatHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _boatHeight;
}
}
}

View File

@ -1,103 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningOars
{
private Color _OarsColor;
private NumberOars _numOars;
public void SetNumberOars(int numberOfRollers)
{
_numOars = NumberOars.FromInteger(numberOfRollers);
}
public void Init(Color trackRollersColor)
{
_OarsColor = trackRollersColor;
}
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY)
{
if (_OarsColor == null)
{
return;
}
gc.setFill(_OarsColor);
gc.fillOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
gc.strokeOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
gc.strokeOval(11.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
gc.fillOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
gc.strokeOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
gc.strokeOval(95.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
switch (_numOars)
{
case One:
gc.setFill(_OarsColor);
gc.fillOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(40.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(68.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
break;
case Two:
gc.setFill(_OarsColor);
gc.fillOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(34.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(54.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(74.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
break;
case Three:
gc.setFill(_OarsColor);
gc.fillOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(30.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(46.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(62.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
gc.setFill(_OarsColor);
gc.fillOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.strokeOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
gc.setFill(Color.BLACK);
gc.fillOval(78.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
break;
}
}
}

View File

@ -1,38 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.paint.Color;
import java.util.Random;
public class EntityBoat
{
private int _speed;
private float _weight;
private Color _bodyColor;
public int GetSpeed()
{
return _speed;
}
public float GetWeight()
{
return _weight;
}
public Color GetBodyColor()
{
return _bodyColor;
}
public float GetStep()
{
return _speed * 100 / _weight;
}
public void Init(int speed, float weight, Color bodyColor)
{
Random random = new Random();
_speed = speed <= 0 ? random.nextInt(5) + 25 : speed;
_weight = weight <= 0 ? random.nextInt(30) + 70 : weight;
_bodyColor = bodyColor;
}
}

View File

@ -1,322 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Random;
public class FormBoat extends Application
{
private Pane _root;
private Scene _scene;
private Canvas _canvas;
private HBox _hBox;
private Button _buttonCreate;
private Button _buttonUp;
private Button _buttonDown;
private Button _buttonLeft;
private Button _buttonRight;
private Label _labelSpeedValue;
private Label _labelWeightValue;
private Label _labelBodyColorValue;
private ComboBox<String> _comboBoxNumOars;
private double _hBoxHeight;
private double _buttonCreateHeight;
private final int _buttonMoveWidth = 30;
private final int _buttonMoveHeight = 30;
private final int _distanceBetweenMoveButtons = 5;
private final double _buttonMargin = 10.0;
private DrawningBoat _boat;
@Override
public void start(Stage stage) throws IOException
{
FXMLLoader fxmlLoader = new FXMLLoader(FormBoat.class.getResource("hello-view.fxml"));
_scene = new Scene(fxmlLoader.load(), 320, 240);
_root = (Pane) _scene.lookup("#root");
_root.setStyle("-fx-background-color: #31374c;");
_canvas = new Canvas();
_root.getChildren().add(_canvas);
InitHBox();
InitButtonCreate();
InitMoveButtons();
stage.setTitle("Armored Vehicle");
stage.setScene(_scene);
_scene.widthProperty().addListener((obs, oldVal, newVal) ->
{
UpdateGUI();
if (_boat != null)
{
_boat.ChangeBorders((int) _canvas.getWidth(), (int) _canvas.getHeight());
}
Draw();
});
_scene.heightProperty().addListener((obs, oldVal, newVal) ->
{
UpdateGUI();
if (_boat != null)
{
_boat.ChangeBorders((int) _canvas.getWidth(), (int) _canvas.getHeight());
}
Draw();
});
_root.applyCss();
_root.layout();
stage.setOnShowing(event -> {
_hBoxHeight = _hBox.getHeight();
_buttonCreateHeight = _buttonCreate.getHeight();
UpdateGUI();
Draw();
});
stage.show();
}
private void InitHBox()
{
_hBox = new HBox();
_hBox.setStyle("-fx-background-color: #31374c;");
_root.getChildren().add(_hBox);
Label labelSpeed = new Label("Speed:");
labelSpeed.setStyle("-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;");
_hBox.getChildren().add(labelSpeed);
_labelSpeedValue = new Label("-");
_labelSpeedValue.setStyle("-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;");
_hBox.getChildren().add(_labelSpeedValue);
Label labelWeight = new Label("Weight:");
labelWeight.setStyle("-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;");
_hBox.getChildren().add(labelWeight);
_labelWeightValue = new Label("-");
_labelWeightValue.setStyle("-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;");
_hBox.getChildren().add(_labelWeightValue);
Label labelHullColor = new Label("Color:");
labelHullColor.setStyle("-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;");
_hBox.getChildren().add(labelHullColor);
_labelBodyColorValue = new Label("-");
_labelBodyColorValue.setStyle("-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;");
_hBox.getChildren().add(_labelBodyColorValue);
Label labelNumOfRollers = new Label("Rollers:");
labelNumOfRollers.setStyle("-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;");
_hBox.getChildren().add(labelNumOfRollers);
ObservableList<String> optionsForTheNumOfRollers = FXCollections.observableArrayList("4", "5", "6");
_comboBoxNumOars = new ComboBox<>(optionsForTheNumOfRollers);
_comboBoxNumOars.setValue("4");
_comboBoxNumOars.setOnAction(e ->
{
if (_boat != null)
{
_boat.GetDrawningOars().SetNumberOars(
Integer.parseInt(_comboBoxNumOars.getValue()));
Draw();
}
});
_hBox.getChildren().add(_comboBoxNumOars);
}
private void InitButtonCreate()
{
_buttonCreate = new Button("Create");
_buttonCreate.setTranslateX(_buttonMargin);
_root.getChildren().add(_buttonCreate);
_buttonCreate.setOnAction(e ->
{
Random rnd = new Random();
_boat = new DrawningBoat();
_boat.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
_boat.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90),
(int) _canvas.getWidth(), (int) _canvas.getHeight());
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(_comboBoxNumOars.getValue()));
_labelSpeedValue.setText(Integer.toString(_boat.GetArmoredVehicle().GetSpeed()));
_labelWeightValue.setText(Double.toString(_boat.GetArmoredVehicle().GetWeight()));
_labelBodyColorValue.setText(_boat.GetArmoredVehicle().GetBodyColor().toString());
Draw();
});
}
private void InitMoveButtons()
{
Image img;
ImageView view;
// Button "Up"
_buttonUp = new Button();
img = new Image("arrowUp.png");
view = new ImageView(img);
view.setFitHeight(14);
view.setFitWidth(14);
_buttonUp.setGraphic(view);
_buttonUp.setPrefWidth(_buttonMoveWidth);
_buttonUp.setPrefHeight(_buttonMoveHeight);
_buttonUp.setOnAction(e ->
{
if (_boat != null)
{
_boat.MoveTransport(Direction.Up);
Draw();
}
});
_root.getChildren().add(_buttonUp);
// Button "Down"
_buttonDown = new Button();
img = new Image("arrowDown.png");
view = new ImageView(img);
view.setFitHeight(14);
view.setFitWidth(14);
_buttonDown.setGraphic(view);
_buttonDown.setPrefWidth(_buttonMoveWidth);
_buttonDown.setPrefHeight(_buttonMoveHeight);
_buttonDown.setOnAction(e ->
{
if (_boat != null)
{
_boat.MoveTransport(Direction.Down);
Draw();
}
});
_root.getChildren().add(_buttonDown);
// Button "Left"
_buttonLeft = new Button();
img = new Image("arrowLeft.png");
view = new ImageView(img);
view.setFitHeight(14);
view.setFitWidth(14);
_buttonLeft.setGraphic(view);
_buttonLeft.setPrefWidth(_buttonMoveWidth);
_buttonLeft.setPrefHeight(_buttonMoveHeight);
_buttonLeft.setOnAction(e ->
{
if (_boat != null)
{
_boat.MoveTransport(Direction.Left);
Draw();
}
});
_root.getChildren().add(_buttonLeft);
// Button "Right"
_buttonRight = new Button();
img = new Image("arrowRight.png");
view = new ImageView(img);
view.setFitHeight(14);
view.setFitWidth(14);
_buttonRight.setGraphic(view);
_buttonRight.setPrefWidth(_buttonMoveWidth);
_buttonRight.setPrefHeight(_buttonMoveHeight);
_buttonRight.setOnAction(e ->
{
if (_boat != null)
{
_boat.MoveTransport(Direction.Right);
Draw();
}
});
_root.getChildren().add(_buttonRight);
}
private void UpdateGUI()
{
double sceneWidth = _scene.getWidth();
double sceneHeight = _scene.getHeight();
_canvas.setWidth(sceneWidth);
_hBox.setPrefWidth(sceneWidth);
_canvas.setHeight(sceneHeight - _hBoxHeight);
_hBox.setTranslateY(sceneHeight - _hBoxHeight);
_buttonCreate.setTranslateY(sceneHeight - _hBoxHeight - _buttonCreateHeight - _buttonMargin);
_buttonUp.setTranslateY(sceneHeight - _hBoxHeight - _buttonMoveHeight * 2.0 - _buttonMargin -
_distanceBetweenMoveButtons);
_buttonUp.setTranslateX(sceneWidth - _buttonMargin - _buttonMoveWidth * 2.0 - _distanceBetweenMoveButtons);
_buttonDown.setTranslateY(sceneHeight - _hBoxHeight - _buttonMoveHeight - _buttonMargin);
_buttonDown.setTranslateX(sceneWidth- _buttonMargin - _buttonMoveWidth * 2.0 - _distanceBetweenMoveButtons);
_buttonLeft.setTranslateY(sceneHeight - _hBoxHeight - _buttonMoveHeight - _buttonMargin);
_buttonLeft.setTranslateX(sceneWidth - _buttonMargin - _buttonMoveWidth * 3.0 -
_distanceBetweenMoveButtons * 2.0);
_buttonRight.setTranslateY(sceneHeight - _hBoxHeight - _buttonMoveHeight - _buttonMargin);
_buttonRight.setTranslateX(sceneWidth - _buttonMargin - _buttonMoveWidth);
}
private void Draw()
{
GraphicsContext gc = _canvas.getGraphicsContext2D();
gc.clearRect(0.0, 0.0, _canvas.getWidth(), _canvas.getHeight());
gc.setFill(Color.WHITE);
gc.fillRect(0.0, 0.0, _canvas.getWidth(), _canvas.getHeight());
gc.setStroke(Color.BLACK);
gc.setLineWidth(4);
gc.strokeRect(0.0, 0.0, _canvas.getWidth(), _canvas.getHeight());
if (_boat != null)
{
_boat.DrawTransport(gc);
}
}
public static void main(String[] args)
{
launch();
}
}

View File

@ -1,27 +0,0 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
public enum NumberOars
{
One,
Two,
Three;
public static NumberOars FromInteger(int intValue)
{
switch(intValue)
{
case 1:
return One;
case 2:
return Two;
case 3:
return Three;
default:
System.out.println("Error: incorrect value for enum");
return One;
}
}
}

View File

@ -0,0 +1,23 @@
package com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}

View File

@ -1,4 +1,4 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
package com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.fxml.FXML;
import javafx.scene.control.Label;

View File

@ -1,10 +1,10 @@
module com.example.pibd22_kalyshev_y_v_motorboat_hard {
module com.zyzf.pibd22_kalyshev_y_v_motorboat_hard {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
requires com.dlsc.formsfx;
opens com.example.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
exports com.example.pibd22_kalyshev_y_v_motorboat_hard;
opens com.zyzf.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
exports com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.Pane?>
<Pane xmlns:fx="http://javafx.com/fxml" fx:id="root">
</Pane>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="com.zyzf.pibd22_kalyshev_y_v_motorboat_hard.HelloController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
<Label fx:id="welcomeText"/>
<Button text="Hello!" onAction="#onHelloButtonClick"/>
</VBox>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.Pane?>
<Pane xmlns:fx="http://javafx.com/fxml" fx:id="root">
</Pane>

Binary file not shown.