Skip to content

Instantly share code, notes, and snippets.

@JonasEmre
Created December 2, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonasEmre/1a2267aea90547c0d90335df2d45c4d3 to your computer and use it in GitHub Desktop.
Save JonasEmre/1a2267aea90547c0d90335df2d45c4d3 to your computer and use it in GitHub Desktop.
# Default ignored files
/shelf/
/workspace.xml
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="true" project-jdk-name="openjdk-15" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/mistik.iml" filepath="$PROJECT_DIR$/mistik.iml" />
</modules>
</component>
</project>
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8104ac5b-ed92-4270-9d8c-1e14b2220578" name="Default Changelist" comment="" />
<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>
<file leaf-file-name="Main.java" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/com/mistik/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="14" selection-start="14" selection-end="14" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="1l6WfYLWpJn9zIMR7gcrOFYA3Ou" />
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1" splitterProportion="0.5">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="company" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
</panes>
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.general" />
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
<option name="MAIN_CLASS_NAME" value="com.mistik.Main" />
<module name="mistik" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="8104ac5b-ed92-4270-9d8c-1e14b2220578" name="Default Changelist" comment="" />
<created>1606918140889</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1606918140889</updated>
</task>
<servers />
</component>
</project>
<?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>
package characters;
import inventory.Inventory;
public abstract class Character {
private String name;
private int strength, dexterity, intelligence, hp, maxHp, mana, maxMana, carryingCapacity;
private Inventory inventory = new Inventory();
public Character(String name, int strength, int dexterity, int intelligence) {
this.name = name;
this.strength = strength;
this.dexterity = dexterity;
this.intelligence = intelligence;
this.maxHp = this.strength;
this.maxMana = this.intelligence;
this.hp = this.maxHp;
this.mana = this.maxMana;
this.carryingCapacity = (this.strength / 2);
}
public String getName() {
return name;
}
public int getStrength() {
return strength;
}
public void setStrength(int strength) {
this.strength = strength;
}
public int getDexterity() {
return dexterity;
}
public void setDexterity(int dexterity) {
this.dexterity = dexterity;
}
public int getIntelligence() {
return intelligence;
}
public void setIntelligence(int intelligence) {
this.intelligence = intelligence;
}
public int getHp() {
return hp;
}
public void setHp(int hp) {
this.hp = hp;
}
public int getMaxHp() {
return this.strength;
}
public int getMana() {
return mana;
}
public void setMana(int mana) {
this.mana = mana;
}
public int getMaxMana() {
return maxMana;
}
public void setMaxMana(int maxMana) {
this.maxMana = maxMana;
}
public int getTotalStats() {
return (this.strength + this.dexterity + this.intelligence);
}
public boolean isAlive() {
return this.hp >= 0;
}
public int getCarryingCapacity() {
return carryingCapacity;
}
public Inventory getInventory() {
return inventory;
}
public void getDamage(int damage){
if(this.isAlive()) {
this.hp -= damage;
if (this.hp < 0) {
this.hp = 0;
}
}
}
}
package characters;
import inventory.Inventory;
public class Humanoid extends Character {
public Humanoid(String name, int strength, int dexterity, int intelligene) {
super(name, strength, dexterity, intelligene);
}
}
package com.mistik;
import characters.Character;
import characters.Humanoid;
import items.Item;
import items.Weapon;
public class Main {
public static void main(String[] args) {
Character habel = new Humanoid("Habel", 90, 90, 45);
Item tempItem = new Weapon("Sword", 12, 3);
habel.getInventory().check();
habel.getInventory().add(tempItem);
habel.getInventory().add(tempItem);
habel.getInventory().add(tempItem);
habel.getInventory().add(tempItem);
System.out.println("*****");
habel.getInventory().check();
}
}
package inventory;
import items.Item;
public class Inventory {
private Item[] inside = new Item[1];
public Item[] getInside() {
return inside;
}
public void add(Item item){
Item[] new_inside = new Item[this.inside.length];
for(int i = 0; i < this.inside.length - 1; i++){
new_inside[i] = this.inside[i];
}
new_inside[new_inside.length - 1] = item;
this.inside = new_inside;
}
public void check(){
for (int i = 0; i <= this.inside.length - 1; i++){
if(this.inside[i] != null){
System.out.println(this.inside[i].getName());
}
else;
System.out.println("Boş");
}
}
}
package items;
public class Armor {
}
package items;
public abstract class Item {
private String name;
private int weight;
private int value;
public Item(String name, int weight, int value){
this.name = name;
this.weight = weight;
this.value = value;
}
public String getName() {
return name;
}
public int getWeight() {
return weight;
}
public int getValue() {
return value;
}
}
package items;
public class Weapon extends Item{
public Weapon(String name, int weight, int value) {
super(name, weight, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment