new updated project
This commit is contained in:
23
.idea/compiler.xml
generated
Normal file
23
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
1
.idea/description.html
generated
Normal file
1
.idea/description.html
generated
Normal file
@@ -0,0 +1 @@
|
||||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
22
.idea/misc.xml
generated
Normal file
22
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="myConfigurationMap">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$">
|
||||
<value>
|
||||
<SvnBranchConfiguration>
|
||||
<option name="trunkUrl" value="https://github.com/Solargale/TaipanClone.git" />
|
||||
</SvnBranchConfiguration>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/TaipanClone.iml" filepath="$PROJECT_DIR$/TaipanClone.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="svn" />
|
||||
</component>
|
||||
</project>
|
||||
337
.idea/workspace.xml
generated
Normal file
337
.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,337 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="" />
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<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="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="3077">
|
||||
<caret line="181" column="1" selection-start-line="181" selection-start-column="1" selection-end-line="181" selection-end-column="1" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#1426#1427#0" expanded="true" />
|
||||
<element signature="e#1454#1455#0" expanded="true" />
|
||||
<element signature="e#1482#1483#0" expanded="true" />
|
||||
<element signature="e#1509#1510#0" expanded="true" />
|
||||
<element signature="e#1535#1536#0" expanded="true" />
|
||||
<element signature="e#1560#1561#0" expanded="true" />
|
||||
<element signature="e#1601#1602#0" expanded="true" />
|
||||
<element signature="e#1641#1642#0" expanded="true" />
|
||||
<element signature="e#1742#1743#0" expanded="true" />
|
||||
<element signature="e#1776#1777#0" expanded="true" />
|
||||
<element signature="e#1813#1814#0" expanded="true" />
|
||||
<element signature="e#1845#1846#0" expanded="true" />
|
||||
<element signature="e#1907#1908#0" expanded="true" />
|
||||
<element signature="e#1965#1966#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/TaipanShop.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="323">
|
||||
<caret line="19" selection-start-line="19" selection-end-line="19" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/src/ShipWarfare.java" />
|
||||
<option value="$PROJECT_DIR$/src/TaipanShop.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="72" />
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1696" />
|
||||
<option name="height" value="1026" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="TaipanClone" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="TaipanClone" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="aspect.path.notification.shown" value="true" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1550455939994" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="project.structure.last.edited" value="SDKs" />
|
||||
<property name="project.structure.proportion" value="0.0" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Application.ShipWarfare">
|
||||
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
|
||||
<option name="MAIN_CLASS_NAME" value="Main" />
|
||||
<module name="TaipanClone" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
<RunnerSettings RunnerId="Run" />
|
||||
<ConfigurationWrapper RunnerId="Run" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="ShipWarfare" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="ShipWarfare" />
|
||||
<module name="TaipanClone" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Application.Main" />
|
||||
<item itemvalue="Application.ShipWarfare" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.ShipWarfare" />
|
||||
<item itemvalue="Application.Main" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration" cleanupOnStartRun="true">
|
||||
<configuration>C:\Users\Harkamal Randhawa\AppData\Roaming\Subversion</configuration>
|
||||
</component>
|
||||
<component name="SvnFileUrlMappingImpl">
|
||||
<option name="myMappingRoots">
|
||||
<list>
|
||||
<SvnCopyRootSimple>
|
||||
<option name="myVcsRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone" />
|
||||
<option name="myCopyRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone" />
|
||||
</SvnCopyRootSimple>
|
||||
<SvnCopyRootSimple>
|
||||
<option name="myVcsRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone\.idea" />
|
||||
<option name="myCopyRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone\.idea" />
|
||||
</SvnCopyRootSimple>
|
||||
</list>
|
||||
</option>
|
||||
<option name="myMoreRealMappingRoots">
|
||||
<list>
|
||||
<SvnCopyRootSimple>
|
||||
<option name="myVcsRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone" />
|
||||
<option name="myCopyRoot" value="C:\Users\Harkamal Randhawa\Desktop\TaipanClone" />
|
||||
</SvnCopyRootSimple>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="" />
|
||||
<created>1550454898506</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1550454898506</updated>
|
||||
<workItem from="1550454902781" duration="459000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="459000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1696" height="1026" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Image Layers" />
|
||||
<window_info id="Designer" />
|
||||
<window_info id="UI Designer" />
|
||||
<window_info id="Capture Tool" />
|
||||
<window_info id="Favorites" side_tool="true" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Messages" />
|
||||
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Database Changes" />
|
||||
<window_info anchor="bottom" id="Version Control" />
|
||||
<window_info anchor="bottom" id="Terminal" />
|
||||
<window_info anchor="bottom" id="Event Log" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32922733" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="right" id="Palette" />
|
||||
<window_info anchor="right" id="Theme Preview" />
|
||||
<window_info anchor="right" id="Maven" />
|
||||
<window_info anchor="right" id="Capture Analysis" />
|
||||
<window_info anchor="right" id="Palette	" />
|
||||
<window_info anchor="right" id="Database" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="This should fix the project repository once and for all." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="This should fix the project repository once and for all." />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/TaipanShop.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="323">
|
||||
<caret line="19" selection-start-line="19" selection-end-line="19" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="3077">
|
||||
<caret line="181" column="1" selection-start-line="181" selection-start-column="1" selection-end-line="181" selection-end-column="1" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#1426#1427#0" expanded="true" />
|
||||
<element signature="e#1454#1455#0" expanded="true" />
|
||||
<element signature="e#1482#1483#0" expanded="true" />
|
||||
<element signature="e#1509#1510#0" expanded="true" />
|
||||
<element signature="e#1535#1536#0" expanded="true" />
|
||||
<element signature="e#1560#1561#0" expanded="true" />
|
||||
<element signature="e#1601#1602#0" expanded="true" />
|
||||
<element signature="e#1641#1642#0" expanded="true" />
|
||||
<element signature="e#1742#1743#0" expanded="true" />
|
||||
<element signature="e#1776#1777#0" expanded="true" />
|
||||
<element signature="e#1813#1814#0" expanded="true" />
|
||||
<element signature="e#1845#1846#0" expanded="true" />
|
||||
<element signature="e#1907#1908#0" expanded="true" />
|
||||
<element signature="e#1965#1966#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ArtifactsStructureConfigurable.UI">
|
||||
<settings>
|
||||
<artifact-editor />
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="FacetStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>No facets are configured</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="GlobalLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="JdkListConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ModuleStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>TaipanClone</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ProjectLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
1
.svn/entries
Normal file
1
.svn/entries
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
1
.svn/format
Normal file
1
.svn/format
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/TaipanClone.iml" filepath="$PROJECT_DIR$/TaipanClone.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,376 @@
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
public class TaipanShop {
|
||||
|
||||
private String name = "Taipan";
|
||||
private int bank = 0;
|
||||
private int money = 1000;
|
||||
private int opiumHeld = 0;
|
||||
private int silkHeld = 0;
|
||||
private int generalHeld = 0;
|
||||
private int armsHeld = 0;
|
||||
private int cargoSpace = 60;
|
||||
private int currentCargo = 0;
|
||||
private int opiumPrice = 16000;
|
||||
private int silkPrice = 1600;
|
||||
private int armsPrice = 160;
|
||||
private int generalPrice = 8;
|
||||
private int location = 2;
|
||||
private int guns = 0;
|
||||
|
||||
public void updatePrices(){
|
||||
String s = "\n" + name + ", the price of ";
|
||||
double value = 80*Math.random();
|
||||
Random rand = new Random();
|
||||
opiumPrice = (rand.nextInt(201) + 60)*100;
|
||||
silkPrice = (rand.nextInt(201) + 60)*10;
|
||||
armsPrice = (rand.nextInt(21) + 6)*10;
|
||||
generalPrice = rand.nextInt(17) + 4;
|
||||
if(value < 8){
|
||||
if(value < 2){
|
||||
if(value < 1){
|
||||
opiumPrice /= 5;
|
||||
System.out.println(s + "Opium has dropped to " + opiumPrice +"!!!\n");
|
||||
}else{
|
||||
opiumPrice *= 5;
|
||||
System.out.println(s + "Opium has risen to " + opiumPrice +"!!!\n");
|
||||
}
|
||||
}else if(value < 4){
|
||||
if(value < 3){
|
||||
silkPrice /= 5;
|
||||
System.out.println(s + "Silk has dropped to " + silkPrice +"!!!\n");
|
||||
}else{
|
||||
silkPrice *= 5;
|
||||
System.out.println(s + "Silk has risen to " + silkPrice +"!!!\n");
|
||||
}
|
||||
}else if(value < 6){
|
||||
if(value < 3){
|
||||
armsPrice /= 5;
|
||||
System.out.println(s + "Arms has dropped to " + armsPrice +"!!!\n");
|
||||
}else{
|
||||
armsPrice *= 5;
|
||||
System.out.println(s + "Arms has risen to " + armsPrice +"!!!\n");
|
||||
}
|
||||
}else{
|
||||
if(value < 7){
|
||||
generalPrice = 1;
|
||||
System.out.println(s + "General Cargo has dropped to 1!!!\n");
|
||||
}else{
|
||||
generalPrice *= 5;
|
||||
System.out.println(s + "General Cargo has risen to " + generalPrice + "!!!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printShop(){
|
||||
currentCargo = opiumHeld+guns*10+silkHeld+armsHeld+generalHeld;
|
||||
if(cargoSpace - currentCargo < 0){
|
||||
System.out.println("Hold: Overloaded" + " Guns: " + guns);
|
||||
}else{
|
||||
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + guns);
|
||||
}
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println(" Opium: " + opiumHeld + " Silk: " + silkHeld);
|
||||
System.out.println(" Arms: " + armsHeld + " General: " + generalHeld);
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println("Cash: " + money + " Bank: " + bank+"\n");
|
||||
System.out.println(name + ", present prices per unit here are:");
|
||||
System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
|
||||
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
|
||||
}
|
||||
|
||||
public void shop() {
|
||||
updatePrices();
|
||||
Scanner input = new Scanner(System.in);
|
||||
boolean notDone = true;
|
||||
if (location == 1) {
|
||||
while (notDone) {
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / opiumPrice && num >= 0) {
|
||||
opiumHeld += num;
|
||||
money -= num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / silkPrice && num >= 0) {
|
||||
silkHeld += num;
|
||||
money -= num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / armsPrice && num >= 0) {
|
||||
armsHeld += num;
|
||||
money -= num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / generalPrice && num >= 0) {
|
||||
generalHeld += num;
|
||||
money -= num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I sell, " + name + "? (You have " + opiumHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= opiumHeld && num >= 0) {
|
||||
opiumHeld -= num;
|
||||
money += num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= silkHeld && num >= 0) {
|
||||
silkHeld -= num;
|
||||
money += num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= armsHeld && num >= 0) {
|
||||
armsHeld -= num;
|
||||
money += num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= generalHeld && num >= 0) {
|
||||
generalHeld -= num;
|
||||
money += num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("V")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
|
||||
} else if (response.equalsIgnoreCase("T")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (notDone) {
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / opiumPrice && num >= 0) {
|
||||
opiumHeld += num;
|
||||
money -= num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / silkPrice && num >= 0) {
|
||||
silkHeld += num;
|
||||
money -= num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / armsPrice && num >= 0) {
|
||||
armsHeld += num;
|
||||
money -= num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / generalPrice && num >= 0) {
|
||||
generalHeld += num;
|
||||
money -= num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + name + "? (You have " + opiumHeld + ")");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I sell, " + name + "?");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= opiumHeld && num >= 0) {
|
||||
opiumHeld -= num;
|
||||
money += num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= silkHeld && num >= 0) {
|
||||
silkHeld -= num;
|
||||
money += num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= armsHeld && num >= 0) {
|
||||
armsHeld -= num;
|
||||
money += num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= generalHeld && num >= 0) {
|
||||
generalHeld -= num;
|
||||
money += num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void main(String[] args){
|
||||
TaipanShop shop = new TaipanShop();
|
||||
shop.shop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,182 @@
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ShipWarfare {
|
||||
|
||||
private int money = 100000000;
|
||||
private int guns = 3;
|
||||
private int hp = 100;
|
||||
private int numOfPeasantShips= 0;
|
||||
|
||||
|
||||
|
||||
public void peasantFleetAttack() throws Exception{
|
||||
Scanner userResponse = new Scanner(System.in);
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
System.out.printf("By Golly! We have $%,d \nwe are being attacked by %d ships\n", getMoney(), getNumOfPeasantShips());
|
||||
System.out.println("What do you want to do? Press \"f\" to fight, and \"r\" to run ");
|
||||
while(true) {
|
||||
try {
|
||||
String response = userResponse.nextLine();
|
||||
if (response.equalsIgnoreCase("f")) {
|
||||
System.out.println("Ohh, fight ehh?");
|
||||
fightShips(getNumOfPeasantShips());
|
||||
}
|
||||
else if(response.equalsIgnoreCase("r")){
|
||||
|
||||
}
|
||||
|
||||
} catch (InputMismatchException e) {
|
||||
String response;
|
||||
System.out.println("Sorry, that is not an acceptable input please try again");
|
||||
response = userResponse.nextLine();
|
||||
if (response.equalsIgnoreCase("f") || response.equalsIgnoreCase("r"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public int getGuns() {
|
||||
return guns;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getNumOfPeasantShips() {
|
||||
return numOfPeasantShips;
|
||||
}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
|
||||
}
|
||||
|
||||
public void setMoney(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public void setGuns(int guns) {
|
||||
this.guns = guns;
|
||||
}
|
||||
public void setNumOfPeasantShips(int numOfPeasantShips) {
|
||||
this.numOfPeasantShips = numOfPeasantShips;
|
||||
}
|
||||
|
||||
public void delayForASecond() throws Exception {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
}
|
||||
|
||||
public void gameOver(){
|
||||
System.out.flush();
|
||||
System.out.println("Game over");
|
||||
}
|
||||
|
||||
public int numOfShips(){
|
||||
|
||||
int numOfShipsAttacking = 0;
|
||||
Random randomValue = new Random();
|
||||
|
||||
if (getMoney() <= 100000){
|
||||
//Minimum one ship will attack, maximum 20
|
||||
numOfShipsAttacking = randomValue.nextInt(20) + 1;
|
||||
}
|
||||
|
||||
else if (getMoney() <= 200000){
|
||||
//Minimum 30 Ships will attack, maximum 70
|
||||
numOfShipsAttacking = randomValue.nextInt(40) + 30;
|
||||
}
|
||||
|
||||
else if (getMoney() <= 500000){
|
||||
//Minimum 50 ships will attack, maximum 140
|
||||
numOfShipsAttacking = randomValue.nextInt(90) + 50;
|
||||
}
|
||||
|
||||
else if (getMoney() > 1000000){
|
||||
//Minimum 100 ships will attack, maximum 300 ships
|
||||
numOfShipsAttacking = randomValue.nextInt(3) + 100;
|
||||
}
|
||||
|
||||
return numOfShipsAttacking;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void fightShips(int typeOfShip) throws Exception {
|
||||
|
||||
Random randomValue = new Random();
|
||||
int shipsRemaining = typeOfShip;
|
||||
int exitValue=0;
|
||||
|
||||
if(typeOfShip==getNumOfPeasantShips()) {
|
||||
//Player volley
|
||||
while (exitValue==0){
|
||||
for (int i = 0; i < shipsRemaining; i++) {
|
||||
for (int j = 0; j < getGuns(); j++) {
|
||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||
if (hitOrMiss == 2) {
|
||||
shipsRemaining--;
|
||||
if (shipsRemaining <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
System.out.println("Got eem");
|
||||
delayForASecond();
|
||||
} else {
|
||||
System.out.println("ARRG! We missed captain");
|
||||
delayForASecond();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (shipsRemaining <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.printf("%d ships remaining\n", shipsRemaining);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForASecond();
|
||||
//Computer volley
|
||||
setHp(getHp() - randomValue.nextInt(10));
|
||||
if(getHp()<=0){
|
||||
exitValue=2;
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, we have %d health left\n", getHp());
|
||||
delayForASecond();
|
||||
|
||||
}
|
||||
}
|
||||
if(exitValue==1) {
|
||||
System.out.printf("Got eem!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", hp);
|
||||
}
|
||||
else if(exitValue==2){
|
||||
gameOver();
|
||||
}
|
||||
|
||||
}
|
||||
//Type of ship implied to be Liu Yen fleet
|
||||
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ShipWarfare littyObject = new ShipWarfare();
|
||||
littyObject.peasantFleetAttack();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
@@ -0,0 +1,2 @@
|
||||
# TaipanClone
|
||||
Computer Science 233 project, Winter 2019
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$USER_HOME$/IdeaProjects/TaipanClone/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
BIN
.svn/wc.db
Normal file
BIN
.svn/wc.db
Normal file
Binary file not shown.
0
.svn/wc.db-journal
Normal file
0
.svn/wc.db-journal
Normal file
12
TaipanClone.iml
Normal file
12
TaipanClone.iml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
BIN
out/production/TaipanClone/ShipWarfare.class
Normal file
BIN
out/production/TaipanClone/ShipWarfare.class
Normal file
Binary file not shown.
BIN
out/production/TaipanClone/TaipanShop.class
Normal file
BIN
out/production/TaipanClone/TaipanShop.class
Normal file
Binary file not shown.
182
src/ShipWarfare.java
Normal file
182
src/ShipWarfare.java
Normal file
@@ -0,0 +1,182 @@
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ShipWarfare {
|
||||
|
||||
private int money = 100000000;
|
||||
private int guns = 3;
|
||||
private int hp = 100;
|
||||
private int numOfPeasantShips= 0;
|
||||
|
||||
|
||||
|
||||
public void peasantFleetAttack() throws Exception{
|
||||
Scanner userResponse = new Scanner(System.in);
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
System.out.printf("By Golly! We have $%,d \nwe are being attacked by %d ships\n", getMoney(), getNumOfPeasantShips());
|
||||
System.out.println("What do you want to do? Press \"f\" to fight, and \"r\" to run ");
|
||||
while(true) {
|
||||
try {
|
||||
String response = userResponse.nextLine();
|
||||
if (response.equalsIgnoreCase("f")) {
|
||||
System.out.println("Ohh, fight ehh?");
|
||||
fightShips(getNumOfPeasantShips());
|
||||
}
|
||||
else if(response.equalsIgnoreCase("r")){
|
||||
|
||||
}
|
||||
|
||||
} catch (InputMismatchException e) {
|
||||
String response;
|
||||
System.out.println("Sorry, that is not an acceptable input please try again");
|
||||
response = userResponse.nextLine();
|
||||
if (response.equalsIgnoreCase("f") || response.equalsIgnoreCase("r"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public int getGuns() {
|
||||
return guns;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public int getNumOfPeasantShips() {
|
||||
return numOfPeasantShips;
|
||||
}
|
||||
|
||||
public void setHp(int hp) {
|
||||
this.hp = hp;
|
||||
|
||||
}
|
||||
|
||||
public void setMoney(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public void setGuns(int guns) {
|
||||
this.guns = guns;
|
||||
}
|
||||
public void setNumOfPeasantShips(int numOfPeasantShips) {
|
||||
this.numOfPeasantShips = numOfPeasantShips;
|
||||
}
|
||||
|
||||
public void delayForASecond() throws Exception {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
}
|
||||
|
||||
public void gameOver(){
|
||||
System.out.flush();
|
||||
System.out.println("Game over");
|
||||
}
|
||||
|
||||
public int numOfShips(){
|
||||
|
||||
int numOfShipsAttacking = 0;
|
||||
Random randomValue = new Random();
|
||||
|
||||
if (getMoney() <= 100000){
|
||||
//Minimum one ship will attack, maximum 20
|
||||
numOfShipsAttacking = randomValue.nextInt(20) + 1;
|
||||
}
|
||||
|
||||
else if (getMoney() <= 200000){
|
||||
//Minimum 30 Ships will attack, maximum 70
|
||||
numOfShipsAttacking = randomValue.nextInt(40) + 30;
|
||||
}
|
||||
|
||||
else if (getMoney() <= 500000){
|
||||
//Minimum 50 ships will attack, maximum 140
|
||||
numOfShipsAttacking = randomValue.nextInt(90) + 50;
|
||||
}
|
||||
|
||||
else if (getMoney() > 1000000){
|
||||
//Minimum 100 ships will attack, maximum 300 ships
|
||||
numOfShipsAttacking = randomValue.nextInt(3) + 100;
|
||||
}
|
||||
|
||||
return numOfShipsAttacking;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void fightShips(int typeOfShip) throws Exception {
|
||||
|
||||
Random randomValue = new Random();
|
||||
int shipsRemaining = typeOfShip;
|
||||
int exitValue=0;
|
||||
|
||||
if(typeOfShip==getNumOfPeasantShips()) {
|
||||
//Player volley
|
||||
while (exitValue==0){
|
||||
for (int i = 0; i < shipsRemaining; i++) {
|
||||
for (int j = 0; j < getGuns(); j++) {
|
||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||
if (hitOrMiss == 2) {
|
||||
shipsRemaining--;
|
||||
if (shipsRemaining <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
System.out.println("Got eem");
|
||||
delayForASecond();
|
||||
} else {
|
||||
System.out.println("ARRG! We missed captain");
|
||||
delayForASecond();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (shipsRemaining <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.printf("%d ships remaining\n", shipsRemaining);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForASecond();
|
||||
//Computer volley
|
||||
setHp(getHp() - randomValue.nextInt(10));
|
||||
if(getHp()<=0){
|
||||
exitValue=2;
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, we have %d health left\n", getHp());
|
||||
delayForASecond();
|
||||
|
||||
}
|
||||
}
|
||||
if(exitValue==1) {
|
||||
System.out.printf("Got eem!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", hp);
|
||||
}
|
||||
else if(exitValue==2){
|
||||
gameOver();
|
||||
}
|
||||
|
||||
}
|
||||
//Type of ship implied to be Liu Yen fleet
|
||||
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ShipWarfare littyObject = new ShipWarfare();
|
||||
littyObject.peasantFleetAttack();
|
||||
}
|
||||
|
||||
}
|
||||
376
src/TaipanShop.java
Normal file
376
src/TaipanShop.java
Normal file
@@ -0,0 +1,376 @@
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
public class TaipanShop {
|
||||
|
||||
private String name = "Taipan";
|
||||
private int bank = 0;
|
||||
private int money = 1000;
|
||||
private int opiumHeld = 0;
|
||||
private int silkHeld = 0;
|
||||
private int generalHeld = 0;
|
||||
private int armsHeld = 0;
|
||||
private int cargoSpace = 60;
|
||||
private int currentCargo = 0;
|
||||
private int opiumPrice = 16000;
|
||||
private int silkPrice = 1600;
|
||||
private int armsPrice = 160;
|
||||
private int generalPrice = 8;
|
||||
private int location = 2;
|
||||
private int guns = 0;
|
||||
|
||||
public void updatePrices(){
|
||||
String s = "\n" + name + ", the price of ";
|
||||
double value = 80*Math.random();
|
||||
Random rand = new Random();
|
||||
opiumPrice = (rand.nextInt(201) + 60)*100;
|
||||
silkPrice = (rand.nextInt(201) + 60)*10;
|
||||
armsPrice = (rand.nextInt(21) + 6)*10;
|
||||
generalPrice = rand.nextInt(17) + 4;
|
||||
if(value < 8){
|
||||
if(value < 2){
|
||||
if(value < 1){
|
||||
opiumPrice /= 5;
|
||||
System.out.println(s + "Opium has dropped to " + opiumPrice +"!!!\n");
|
||||
}else{
|
||||
opiumPrice *= 5;
|
||||
System.out.println(s + "Opium has risen to " + opiumPrice +"!!!\n");
|
||||
}
|
||||
}else if(value < 4){
|
||||
if(value < 3){
|
||||
silkPrice /= 5;
|
||||
System.out.println(s + "Silk has dropped to " + silkPrice +"!!!\n");
|
||||
}else{
|
||||
silkPrice *= 5;
|
||||
System.out.println(s + "Silk has risen to " + silkPrice +"!!!\n");
|
||||
}
|
||||
}else if(value < 6){
|
||||
if(value < 3){
|
||||
armsPrice /= 5;
|
||||
System.out.println(s + "Arms has dropped to " + armsPrice +"!!!\n");
|
||||
}else{
|
||||
armsPrice *= 5;
|
||||
System.out.println(s + "Arms has risen to " + armsPrice +"!!!\n");
|
||||
}
|
||||
}else{
|
||||
if(value < 7){
|
||||
generalPrice = 1;
|
||||
System.out.println(s + "General Cargo has dropped to 1!!!\n");
|
||||
}else{
|
||||
generalPrice *= 5;
|
||||
System.out.println(s + "General Cargo has risen to " + generalPrice + "!!!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printShop(){
|
||||
currentCargo = opiumHeld+guns*10+silkHeld+armsHeld+generalHeld;
|
||||
if(cargoSpace - currentCargo < 0){
|
||||
System.out.println("Hold: Overloaded" + " Guns: " + guns);
|
||||
}else{
|
||||
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + guns);
|
||||
}
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println(" Opium: " + opiumHeld + " Silk: " + silkHeld);
|
||||
System.out.println(" Arms: " + armsHeld + " General: " + generalHeld);
|
||||
System.out.println("-------------------------------------------------------------");
|
||||
System.out.println("Cash: " + money + " Bank: " + bank+"\n");
|
||||
System.out.println(name + ", present prices per unit here are:");
|
||||
System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
|
||||
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
|
||||
}
|
||||
|
||||
public void shop() {
|
||||
updatePrices();
|
||||
Scanner input = new Scanner(System.in);
|
||||
boolean notDone = true;
|
||||
if (location == 1) {
|
||||
while (notDone) {
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / opiumPrice && num >= 0) {
|
||||
opiumHeld += num;
|
||||
money -= num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / silkPrice && num >= 0) {
|
||||
silkHeld += num;
|
||||
money -= num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / armsPrice && num >= 0) {
|
||||
armsHeld += num;
|
||||
money -= num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / generalPrice && num >= 0) {
|
||||
generalHeld += num;
|
||||
money -= num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I sell, " + name + "? (You have " + opiumHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= opiumHeld && num >= 0) {
|
||||
opiumHeld -= num;
|
||||
money += num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= silkHeld && num >= 0) {
|
||||
silkHeld -= num;
|
||||
money += num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= armsHeld && num >= 0) {
|
||||
armsHeld -= num;
|
||||
money += num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= generalHeld && num >= 0) {
|
||||
generalHeld -= num;
|
||||
money += num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("V")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR BANK ***\n");
|
||||
} else if (response.equalsIgnoreCase("T")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR WAREHOUSE ***\n");
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (notDone) {
|
||||
printShop();
|
||||
System.out.println("\nShall I Buy, Sell, or Quit Trading?");
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to buy, " + name + "?");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I buy, " + name + "? (You can afford " + money / opiumPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / opiumPrice && num >= 0) {
|
||||
opiumHeld += num;
|
||||
money -= num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I buy, " + name + "? (You can afford " + money / silkPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / silkPrice && num >= 0) {
|
||||
silkHeld += num;
|
||||
money -= num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I buy, " + name + "? (You can afford " + money / armsPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / armsPrice && num >= 0) {
|
||||
armsHeld += num;
|
||||
money -= num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I buy, " + name + "? (You can afford " + money / generalPrice + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= money / generalPrice && num >= 0) {
|
||||
generalHeld += num;
|
||||
money -= num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you can't afford that!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
boolean notDone2 = true;
|
||||
System.out.println("What do you wish me to sell, " + name + "? (You have " + opiumHeld + ")");
|
||||
while (notDone2) {
|
||||
response = input.nextLine();
|
||||
if (response.equalsIgnoreCase("O")) {
|
||||
System.out.println("\nHow much Opium shall I sell, " + name + "?");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= opiumHeld && num >= 0) {
|
||||
opiumHeld -= num;
|
||||
money += num * opiumPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("S")) {
|
||||
System.out.println("\nHow much Silk shall I sell, " + name + "? (You have " + silkHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= silkHeld && num >= 0) {
|
||||
silkHeld -= num;
|
||||
money += num * silkPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("A")) {
|
||||
System.out.println("\nHow many Arms shall I sell, " + name + "? (You have " + armsHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= armsHeld && num >= 0) {
|
||||
armsHeld -= num;
|
||||
money += num * armsPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("G")) {
|
||||
System.out.println("\nHow much General Cargo shall I sell, " + name + "? (You have " + generalHeld + ")");
|
||||
while (notDone2) {
|
||||
int num = input.nextInt();
|
||||
if (num <= generalHeld && num >= 0) {
|
||||
generalHeld -= num;
|
||||
money += num * generalPrice;
|
||||
notDone2 = false;
|
||||
} else if (num >= 0) {
|
||||
System.out.println(name + ", you don't have that many to sell!");
|
||||
} else {
|
||||
System.out.println(name + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (response.equalsIgnoreCase("Q")) {
|
||||
System.out.println("\n*** PLACEHOLDER FOR TRAVEL ***\n");
|
||||
notDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void main(String[] args){
|
||||
TaipanShop shop = new TaipanShop();
|
||||
shop.shop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user