Compare commits
No commits in common. "f0844a65640d58e82673c26e8ee5ff25a785cde8" and "9c6e536bffecfce634b9ecd169be213fd4b4143a" have entirely different histories.
f0844a6564
...
9c6e536bff
|
@ -1,2 +0,0 @@
|
||||||
Assignment 2/out/
|
|
||||||
out/
|
|
|
@ -1,8 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
|
@ -1,5 +0,0 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
|
@ -1 +0,0 @@
|
||||||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<entry_points version="2.0" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectKey">
|
|
||||||
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
|
|
||||||
</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>
|
|
||||||
</project>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/untitled104.iml" filepath="$PROJECT_DIR$/untitled104.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<template>
|
|
||||||
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
|
|
||||||
</template>
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Palette2">
|
|
||||||
<group name="Swing">
|
|
||||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Button" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="RadioButton" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="CheckBox" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Label" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
|
||||||
<preferred-size width="-1" height="20" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,35 +0,0 @@
|
||||||
package ca.cosc3p91.a2;
|
|
||||||
|
|
||||||
import ca.cosc3p91.a2.game.GameEngine;
|
|
||||||
import ca.cosc3p91.a2.util.Print;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
GameEngine engine = new GameEngine();
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
engine.printMap();
|
|
||||||
=======
|
|
||||||
Print test = new Print("Hello There", 2);
|
|
||||||
|
|
||||||
test.addColumn(new Print.Column("I am value 1"));
|
|
||||||
test.addColumn(new Print.Column("Super Value"));
|
|
||||||
test.addColumn(new Print.Column("SOLD!"));
|
|
||||||
|
|
||||||
Print.Row row = new Print.Row();
|
|
||||||
row.add("HelloThere");
|
|
||||||
row.add("Goodbye");
|
|
||||||
row.add("3");
|
|
||||||
|
|
||||||
test.addRow(row);
|
|
||||||
test.addRow(row);
|
|
||||||
test.addRow(row);
|
|
||||||
|
|
||||||
Print.print(test.createTable());
|
|
||||||
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
engine.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package ca.cosc3p91.a2.game;
|
|
||||||
|
|
||||||
import ca.cosc3p91.a2.gameobjects.Building;
|
|
||||||
import ca.cosc3p91.a2.gameobjects.VillageStage;
|
|
||||||
import ca.cosc3p91.a2.gameobjects.Village_Hall;
|
|
||||||
import ca.cosc3p91.a2.player.Player;
|
|
||||||
|
|
||||||
public class GameEngine implements Runnable {
|
|
||||||
|
|
||||||
private final boolean running = true;
|
|
||||||
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
private int pillageFactor;
|
|
||||||
|
|
||||||
private int currentTime;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public GameEngine () {
|
|
||||||
player = new Player();
|
|
||||||
VillageStage vInitialStage = new VillageStage(100,0,2,30,0,
|
|
||||||
0, 12,12,12);
|
|
||||||
map = new Map(new Village_Hall(1,vInitialStage),30);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printMap() {
|
|
||||||
System.out.println("~ Current Map State ~\n\n");
|
|
||||||
System.out.println("In Map:\n");
|
|
||||||
for (Building b : map.contains) {
|
|
||||||
System.out.println("|> "+b.getClass().toString()+" lvl: "+b.getLevel()+" health: "+b.getHealth());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attackVillage(Map map) {
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public Map map;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public void attackVIllage(Map map) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map generateMap() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getScore(Map map) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (running) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package ca.cosc3p91.a2.game;
|
|
||||||
|
|
||||||
import ca.cosc3p91.a2.gameobjects.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public class Map {
|
|
||||||
|
|
||||||
static int MAXSIZE = 400;
|
|
||||||
|
|
||||||
private Village_Hall townHall;
|
|
||||||
=======
|
|
||||||
|
|
||||||
public class Map {
|
|
||||||
|
|
||||||
private Village_Hall townHall;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
private int guardTime;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public List<Building> contains;
|
|
||||||
=======
|
|
||||||
private List<Building> contains;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public List<Inhabitant> inhabitants;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public Map (Village_Hall villageHall, int gTime) {
|
|
||||||
contains = new ArrayList<>();
|
|
||||||
inhabitants = new ArrayList<>();
|
|
||||||
this.townHall = villageHall;
|
|
||||||
this.contains.add(villageHall);
|
|
||||||
this.guardTime = gTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void move(Infantry i, Tile t) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void inRange(Infantry i, Building b) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build(Village_Hall hall, Tile t, Building b) {
|
|
||||||
contains.add(b);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public void move(Infantry i, Tile t) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void inRange(Infantry i, Building b) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build(Village_Hall hall, Tile t, Building b) {
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public int getGuardTime() {
|
|
||||||
return guardTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public void setGuardTime(int gTime) {
|
|
||||||
this.guardTime = gTime;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public void setGuardTime() {
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Archer extends Infantry {
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class ArcherTower extends DefenseBuilding {
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public abstract class Building {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// members
|
|
||||||
private int level;
|
|
||||||
private int health;
|
|
||||||
|
|
||||||
private Stage stage;
|
|
||||||
|
|
||||||
private int goldCost;
|
|
||||||
private int ironCost;
|
|
||||||
private int woodCost;
|
|
||||||
=======
|
|
||||||
private static int level;
|
|
||||||
|
|
||||||
private int health;
|
|
||||||
|
|
||||||
private static Stage stages;
|
|
||||||
|
|
||||||
private int goldCost;
|
|
||||||
|
|
||||||
private int ironCost;
|
|
||||||
|
|
||||||
private int woodCost;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
private int buildTime;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public ArrayList<Tile> tiles = new ArrayList<>();
|
|
||||||
public ArrayList<Inhabitant> inhabitants = new ArrayList<>();
|
|
||||||
|
|
||||||
// functions
|
|
||||||
=======
|
|
||||||
public List<Stage> stage;
|
|
||||||
public Tile tile;
|
|
||||||
|
|
||||||
public List<Inhabitant> inhabitant;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public int getLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHealth() {
|
|
||||||
return health;
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public int getCost(String type) {
|
|
||||||
return (type.equals("gold"))?(goldCost):
|
|
||||||
(type.equals("iron"))?(ironCost):woodCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stage getStage() {
|
|
||||||
return stage;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public int getCost(String type) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public int getUpgradeCost() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public void setLevel(int level) {
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHealth(int health) {
|
|
||||||
this.health = health;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStage(Stage stage) {this.stage = stage; }
|
|
||||||
|
|
||||||
public void addInhabitant(Inhabitant newMember) {
|
|
||||||
inhabitants.add(newMember);
|
|
||||||
// newMember.setBuilding(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void upgrade(Stage stage) {
|
|
||||||
this.stage = stage;
|
|
||||||
this.health += stage.dHealth;
|
|
||||||
// interact with the timer regarding Upgrade time
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBuildTime() {
|
|
||||||
return buildTime;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public void upgrade() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBuildTime() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Cannon extends DefenseBuilding {
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Catapult extends Infantry {
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Collector {
|
|
||||||
|
|
||||||
private int averageCollectionRate;
|
|
||||||
|
|
||||||
public int getCollectionRate() {
|
|
||||||
return averageCollectionRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class DefenseBuilding extends Building {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
private int damage;
|
|
||||||
private int range;
|
|
||||||
|
|
||||||
public void upgrade(DefenseStage stage) {
|
|
||||||
super.upgrade(stage);
|
|
||||||
this.damage += stage.getDamageChange();
|
|
||||||
this.range += stage.getRangeChange();
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public int damage;
|
|
||||||
|
|
||||||
public int range;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public void attack(Infantry attacker) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
class DefenseStage extends Stage {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
protected int dDamage;
|
|
||||||
=======
|
|
||||||
protected int dDamge;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
protected int dRange;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public DefenseStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
|
|
||||||
int damageIncrease, int rangeIncrease) {
|
|
||||||
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
|
|
||||||
this.dDamage = damageIncrease;
|
|
||||||
this.dRange = rangeIncrease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDamageChange() {
|
|
||||||
return dDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRangeChange() {
|
|
||||||
return dRange;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public void getDamageChange() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getRangeChange() {
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Farm extends ResourceBuilding {
|
|
||||||
|
|
||||||
public Farm (int lvl, ResourceStage baseStage) {
|
|
||||||
setLevel(lvl);
|
|
||||||
upgrade(baseStage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPopulationContribution() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class GoldMine extends ResourceBuilding {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public static String resource = "gold";
|
|
||||||
|
|
||||||
public GoldMine (int lvl, ResourceStage baseStage) {
|
|
||||||
setLevel(lvl);
|
|
||||||
upgrade(baseStage);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public static String resource = "good";
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public abstract class Infantry {
|
|
||||||
|
|
||||||
private int health;
|
|
||||||
|
|
||||||
private int damage;
|
|
||||||
|
|
||||||
private int range;
|
|
||||||
|
|
||||||
public void attack(Building b) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getHealth() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getDamage() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getRange() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
import ca.cosc3p91.a2.game.Map;
|
|
||||||
|
|
||||||
public interface Inhabitant {
|
|
||||||
|
|
||||||
Map map = null;
|
|
||||||
Building building = null;
|
|
||||||
|
|
||||||
void move(Tile t);
|
|
||||||
|
|
||||||
void getPosition();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class IronMine extends ResourceBuilding {
|
|
||||||
|
|
||||||
public static String resource = "iron";
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public IronMine (int lvl, ResourceStage baseStage) {
|
|
||||||
setLevel(lvl);
|
|
||||||
upgrade(baseStage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
=======
|
|
||||||
@Override
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Knight extends Infantry {
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class LumberMine extends ResourceBuilding {
|
|
||||||
|
|
||||||
public static String resource = "wood";
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public LumberMine (int lvl, ResourceStage baseStage) {
|
|
||||||
setLevel(lvl);
|
|
||||||
upgrade(baseStage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
=======
|
|
||||||
public void harvest(Village_Hall hall) {
|
|
||||||
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public abstract class ResourceBuidling extends Building {
|
|
||||||
|
|
||||||
public static String resource;
|
|
||||||
|
|
||||||
private int harvest_rate;
|
|
||||||
|
|
||||||
public abstract void harvest(Village_Hall hall);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public abstract class ResourceBuilding extends Building {
|
|
||||||
|
|
||||||
public static String resource;
|
|
||||||
private int harvest_rate;
|
|
||||||
|
|
||||||
public void upgrade(ResourceStage stage) {
|
|
||||||
super.upgrade(stage);
|
|
||||||
this.harvest_rate += stage.getHarvestRateIncrease();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void harvest(Village_Hall hall);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class ResourceStage extends Stage {
|
|
||||||
|
|
||||||
protected int harvestRateIncrease;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public ResourceStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
|
|
||||||
int harvestRateIncr) {
|
|
||||||
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
|
|
||||||
this.harvestRateIncrease = harvestRateIncr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHarvestRateIncrease() {
|
|
||||||
return harvestRateIncrease;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public int getHarvestRateIncrease() {
|
|
||||||
return harvestRateIncrease;
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Soldier extends Infantry {
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
abstract class Stage {
|
|
||||||
|
|
||||||
protected int dHealth;
|
|
||||||
|
|
||||||
protected int goldCost;
|
|
||||||
|
|
||||||
protected int requiredVillageLevel;
|
|
||||||
|
|
||||||
protected int upgradeTime;
|
|
||||||
|
|
||||||
protected int ironCost;
|
|
||||||
|
|
||||||
protected int woodCost;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public Stage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost) {
|
|
||||||
this.dHealth = dHealth;
|
|
||||||
this.goldCost = goldCost;
|
|
||||||
this.requiredVillageLevel = requiredVillageLevel;
|
|
||||||
this.upgradeTime = upgradeTime;
|
|
||||||
this.ironCost = ironCost;
|
|
||||||
this.woodCost = woodCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHealthChange() {
|
|
||||||
return dHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCost(String type) {
|
|
||||||
return (type.equals("gold"))?(goldCost):
|
|
||||||
(type.equals("iron"))?(ironCost):woodCost;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public Building building;
|
|
||||||
|
|
||||||
public void getHealthChange() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCost(String type) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public int getRequiredVillageLevel() {
|
|
||||||
return requiredVillageLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUpgradeTime() {
|
|
||||||
return upgradeTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Tile {
|
|
||||||
|
|
||||||
public int x;
|
|
||||||
|
|
||||||
public int y;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
public List<Building> building;
|
|
||||||
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class VillageStage extends Stage {
|
|
||||||
|
|
||||||
protected int goldCapacityIncrease;
|
|
||||||
|
|
||||||
protected int ironCapacityIncrease;
|
|
||||||
|
|
||||||
protected int woodCapacityIncrease;
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public VillageStage(int dHealth, int goldCost, int requiredVillageLevel, int upgradeTime, int ironCost, int woodCost,
|
|
||||||
int goldCapIncrease, int ironCapIncrease, int woodCapIncrease) {
|
|
||||||
super(dHealth,goldCost,requiredVillageLevel,upgradeTime,ironCost,woodCost);
|
|
||||||
this.goldCapacityIncrease = goldCapIncrease;
|
|
||||||
this.ironCapacityIncrease = ironCapIncrease;
|
|
||||||
this.woodCapacityIncrease = woodCapIncrease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGoldCapacityIncrease() {
|
|
||||||
return goldCapacityIncrease;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
public int getGoldCapacityIncrease() {
|
|
||||||
return goldCapacityIncrease;
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
public int getIronCapacityIncrease() {
|
|
||||||
return ironCapacityIncrease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWoodCapacityIncrease() {
|
|
||||||
return woodCapacityIncrease;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Village_Hall extends Building {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
private int goldCapacity = 0;
|
|
||||||
|
|
||||||
private int ironCapacity = 0;
|
|
||||||
|
|
||||||
private int woodCapacity = 0;
|
|
||||||
|
|
||||||
public Village_Hall (int lvl, VillageStage baseStage) {
|
|
||||||
setLevel(lvl);
|
|
||||||
upgrade(baseStage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void upgrade(VillageStage stage) {
|
|
||||||
super.upgrade(stage);
|
|
||||||
this.goldCapacity += stage.getGoldCapacityIncrease();
|
|
||||||
this.ironCapacity += stage.getIronCapacityIncrease();
|
|
||||||
this.woodCapacity += stage.getWoodCapacityIncrease();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getGoldCapacity() {
|
|
||||||
return goldCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIronCapacity() {
|
|
||||||
return ironCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWoodCapacity() {
|
|
||||||
return woodCapacity;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
private int goldCapacity;
|
|
||||||
|
|
||||||
private int ironCapacity;
|
|
||||||
|
|
||||||
private int woodCapacity;
|
|
||||||
|
|
||||||
public int getGoldCapacity() {
|
|
||||||
return goldCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIronCapacity() {
|
|
||||||
return ironCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWoodCapacity() {
|
|
||||||
return woodCapacity;
|
|
||||||
}
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package ca.cosc3p91.a2.gameobjects;
|
|
||||||
|
|
||||||
public class Worker {
|
|
||||||
|
|
||||||
private boolean currentlyBuilding;
|
|
||||||
|
|
||||||
public boolean isCurrentlyBuilding() {
|
|
||||||
return currentlyBuilding;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package ca.cosc3p91.a2.player;
|
|
||||||
|
|
||||||
public class Player {
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public int currentGold;
|
|
||||||
public int currentIron;
|
|
||||||
public int currentWood;
|
|
||||||
=======
|
|
||||||
public int currentGold;
|
|
||||||
|
|
||||||
public int currentIron;
|
|
||||||
|
|
||||||
public int currentWood;
|
|
||||||
>>>>>>> abf784868daa920a9ca8b3b9d291a7cf521aa9c7
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package ca.cosc3p91.a2.userinterface;
|
|
||||||
|
|
||||||
public class GuiManager {
|
|
||||||
}
|
|
|
@ -1,208 +0,0 @@
|
||||||
package ca.cosc3p91.a2.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ported from blt::TableFormatter (C++)
|
|
||||||
* https://github.com/Tri11Paragon/BLT/
|
|
||||||
*/
|
|
||||||
public class Print {
|
|
||||||
|
|
||||||
public static class Row {
|
|
||||||
private final ArrayList<String> values;
|
|
||||||
|
|
||||||
public Row(ArrayList<String> row) {
|
|
||||||
this.values = row;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Row(){
|
|
||||||
this.values = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(String value){
|
|
||||||
values.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Column {
|
|
||||||
private final String columnName;
|
|
||||||
private long maxColumnLength = 0;
|
|
||||||
|
|
||||||
public Column(String columnName){
|
|
||||||
this.columnName = columnName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final ArrayList<Row> rows = new ArrayList<>();
|
|
||||||
private final ArrayList<Column> columns = new ArrayList<>();
|
|
||||||
|
|
||||||
private final String tableName;
|
|
||||||
private final int columnPadding;
|
|
||||||
private int maxColumnWidth;
|
|
||||||
|
|
||||||
public Print(String tableName, int columnPadding){
|
|
||||||
this.tableName = tableName;
|
|
||||||
this.columnPadding = columnPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Print(){
|
|
||||||
this("", 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String createPadding(int amount) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i < amount; i++){
|
|
||||||
builder.append(' ');
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateTopSelector(long size) {
|
|
||||||
long sizeOfName = tableName.isEmpty() ? 0 : tableName.length() + 4;
|
|
||||||
long sizeNameRemoved = size - sizeOfName;
|
|
||||||
|
|
||||||
StringBuilder halfWidthLeftSeparator = new StringBuilder();
|
|
||||||
StringBuilder halfWidthRightSeparator = new StringBuilder();
|
|
||||||
|
|
||||||
long sizeNameFloor = (long) Math.floor((double)sizeNameRemoved / 2.0);
|
|
||||||
long sizeNameCeil = (long) Math.ceil((double)sizeNameRemoved / 2.0);
|
|
||||||
|
|
||||||
halfWidthLeftSeparator.append('+');
|
|
||||||
|
|
||||||
for (int i = 0; i < sizeNameFloor - 1; i++)
|
|
||||||
halfWidthLeftSeparator.append('-');
|
|
||||||
for (int i = 0; i < sizeNameCeil - 1; i++)
|
|
||||||
halfWidthRightSeparator.append('-');
|
|
||||||
|
|
||||||
halfWidthRightSeparator.append('+');
|
|
||||||
|
|
||||||
StringBuilder separator = new StringBuilder();
|
|
||||||
separator.append(halfWidthLeftSeparator.toString());
|
|
||||||
if (sizeOfName != 0){
|
|
||||||
separator.append("{ ");
|
|
||||||
separator.append(tableName);
|
|
||||||
separator.append(" }");
|
|
||||||
}
|
|
||||||
separator.append(halfWidthRightSeparator);
|
|
||||||
return separator.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateColumnHeader(){
|
|
||||||
updateColumnLengths();
|
|
||||||
StringBuilder header = new StringBuilder();
|
|
||||||
header.append('|');
|
|
||||||
|
|
||||||
for (int i = 0; i < columns.size(); i++){
|
|
||||||
Column column = columns.get(i);
|
|
||||||
double columnPaddingLength = ((int)(column.maxColumnLength) - (int)(column.columnName.length()))/2.0;
|
|
||||||
header.append(createPadding((int)(columnPadding + (int)Math.floor(columnPaddingLength))));
|
|
||||||
|
|
||||||
header.append(column.columnName);
|
|
||||||
|
|
||||||
header.append(createPadding((int)(columnPadding + (int)Math.ceil(columnPaddingLength))));
|
|
||||||
if (i < columns.size()-1)
|
|
||||||
header.append('|');
|
|
||||||
}
|
|
||||||
header.append('|');
|
|
||||||
|
|
||||||
return header.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateSeparator(long size) {
|
|
||||||
int nextIndex = 0;
|
|
||||||
int currentColumnIndex = 0;
|
|
||||||
StringBuilder wholeWidthSeparator = new StringBuilder();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (i == nextIndex) {
|
|
||||||
System.out.println(currentColumnIndex + " " + nextIndex + " " + size);
|
|
||||||
int currentColumnSize = (int) (columns.get(currentColumnIndex++).maxColumnLength + columnPadding*2);
|
|
||||||
nextIndex += currentColumnSize + 1;
|
|
||||||
wholeWidthSeparator.append('+');
|
|
||||||
} else
|
|
||||||
wholeWidthSeparator.append('-');
|
|
||||||
}
|
|
||||||
wholeWidthSeparator.append('+');
|
|
||||||
return wholeWidthSeparator.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateColumnLengths() {
|
|
||||||
for (int i = 0; i < columns.size(); i++) {
|
|
||||||
Column column = columns.get(i);
|
|
||||||
column.maxColumnLength = column.columnName.length();
|
|
||||||
for (Row row : rows) {
|
|
||||||
column.maxColumnLength = Math.max(column.maxColumnLength, row.values.get(i).length() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long columnSize(Column column) {
|
|
||||||
return column.columnName.length() + columnPadding * 2L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Print addColumn(Column column){
|
|
||||||
columns.add(column);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Print addRow(Row row) {
|
|
||||||
if (row.values.size() > columns.size())
|
|
||||||
throw new RuntimeException("Unable to create row with more values than columns!");
|
|
||||||
if (row.values.size() < columns.size())
|
|
||||||
for (int i = row.values.size(); i < columns.size(); i++)
|
|
||||||
row.values.add("");
|
|
||||||
rows.add(row);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Print addRow(ArrayList<String> row){
|
|
||||||
return addRow(new Row(row));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> createTable(boolean top, boolean bottom, boolean separators){
|
|
||||||
ArrayList<String> lines = new ArrayList<>();
|
|
||||||
|
|
||||||
String header = generateColumnHeader();
|
|
||||||
String topSeparator = generateTopSelector(header.length());
|
|
||||||
String lineSeparator = generateSeparator(header.length() - 1);
|
|
||||||
|
|
||||||
if (top)
|
|
||||||
lines.add(topSeparator);
|
|
||||||
|
|
||||||
lines.add(header);
|
|
||||||
lines.add(lineSeparator);
|
|
||||||
|
|
||||||
for (Row row : rows) {
|
|
||||||
StringBuilder rowLine = new StringBuilder();
|
|
||||||
rowLine.append('|');
|
|
||||||
for (int i = 0; i < row.values.size(); i++){
|
|
||||||
String value = row.values.get(i);
|
|
||||||
Column column = columns.get(i);
|
|
||||||
int spaceLeft = (int)(column.maxColumnLength - value.length());
|
|
||||||
rowLine.append(createPadding((int)Math.floor(spaceLeft / 2.0) + columnPadding));
|
|
||||||
rowLine.append(value);
|
|
||||||
rowLine.append(createPadding((int)Math.ceil(spaceLeft / 2.0) + columnPadding));
|
|
||||||
rowLine.append('|');
|
|
||||||
}
|
|
||||||
lines.add(rowLine.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bottom)
|
|
||||||
lines.add(lineSeparator);
|
|
||||||
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> createBox(){
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> createTable() {
|
|
||||||
return createTable(true, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void print(ArrayList<String> lines){
|
|
||||||
for (String line : lines)
|
|
||||||
System.out.println(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package ca.cosc3p91.a2.util;
|
|
||||||
|
|
||||||
public class Time {
|
|
||||||
|
|
||||||
private long timeSeconds;
|
|
||||||
|
|
||||||
public Time() {
|
|
||||||
this.timeSeconds = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Time(long timeSeconds) {
|
|
||||||
this.timeSeconds = timeSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Time offsetSeconds(long seconds) {
|
|
||||||
this.timeSeconds += seconds;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Time offsetMinutes(long minutes) {
|
|
||||||
return offsetSeconds(minutes * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Time offsetHours(long hours) {
|
|
||||||
return offsetMinutes(hours * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Time offsetDays(long days) {
|
|
||||||
return offsetHours(days * 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Time offsetTime(Time time) {
|
|
||||||
return offsetSeconds(time.timeSeconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long get() {
|
|
||||||
return timeSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class FutureTime {
|
|
||||||
private final Time futureTime;
|
|
||||||
|
|
||||||
public FutureTime(Time futureTime) {
|
|
||||||
this.futureTime = futureTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean occurred() {
|
|
||||||
return getTime().timeSeconds >= futureTime.timeSeconds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Time getTime() {
|
|
||||||
return new Time(System.currentTimeMillis() / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,11 +0,0 @@
|
||||||
<?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$/Assignment 2/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
Loading…
Reference in New Issue