Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/Armor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Armor
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 29.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Armor extends Item {
private int defence;

public Armor(String name, String description, int weight, int value, int defence){
super(name, description, weight, value);
this.defence = defence;
}

public void describe(){
super.describe();
System.out.println("Defence = " + this.defence);
}
}
35 changes: 35 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Item
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 18.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Item {
protected String name, description;
protected int weight, value;

public Item(String name, String description, int weight, int value){
this.name = name;
this.description = description;
this.weight = weight;
this.value = value;
}

public void describe(){
System.out.println("Name = " + this.name);
System.out.println("Description = " + this.description);
System.out.println("Weight = " + this.weight + " lbs");
System.out.println("Value = " + this.value + " gold coins");
}
}
30 changes: 30 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/ItemTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_ItemTest
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 18.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class ItemTest {
public static void main(String[] args) {
Item[] items = {
new Item("Excalibur", "The legendary sword of King Arthur", 12, 1024),
new Item("Steel Armor", "Protective covering made by steel", 15, 805)
};

for(Item item : items){
item.describe();
System.out.println();
}
}
}
30 changes: 30 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/ItemTest2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_ItemTest2
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 29.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class ItemTest2 {
public static void main(String[] args) {
Item[] items = {
new Weapon("Excalibur", "The legendary sword of King Arthur", 12, 1024, 24),
new Armor("Steel Armor", "Protective covering made by steel", 15, 805, 18)
};

for(Item item : items){
item.describe();
System.out.println();
}
}
}
33 changes: 33 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/Potion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Potion
*
* 1. 개요 :
* 2. 작성일 : 2017. 6. 5.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Potion extends Item {
String type;
int capacity;

public Potion(String name, String description, int weight, int value, String type, int capacity){
super(name, description, weight, value);
this.type = type;
this.capacity = capacity;
}

public void describe(){
super.describe();
System.out.println("Type = " + this.type);
System.out.println("Capacity = " + this.capacity);
}
}
35 changes: 35 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/Shop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Shop
*
* 1. 개요 :
* 2. 작성일 : 2017. 6. 5.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Shop {
String name;
Item[] items;

public Shop(String name, Item[] items){
this.name = name;
this.items = items;
}

public void showItemList(){
System.out.println("Welcome to " + this.name + " Shop!");
System.out.println("- Item List -");
for(Item item : items){
item.describe();
System.out.println();
}
}
}
72 changes: 72 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/ShopTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
*
*/
package whiteWeed.gameShop;

import java.util.*;

/**
* <pre>
* whiteWeed.gameShop
* |_ShopTest
*
* 1. 개요 :
* 2. 작성일 : 2017. 6. 5.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class ShopTest {
private static Item[][] items = {
{
new Weapon("Sword", "Medium DMG", 3, 10, 10),
new Armor("Cap", "Light Armor", 1, 5, 5),
new Armor("Gloves", "Light Armor", 1, 5, 5),
new Weapon("Axe", "High DMG", 5, 15, 15),
new Armor("Boots", "Light Armor", 1, 5, 5)
},
{
new Potion("Small Health Potion", "Recovery 100 HP", 2, 5, "Health", 100),
new Potion("Small Mana Potion", "Recovery 50 MP", 1, 30, "Mana", 50),
new Potion("Medium Health Potion", "Recovery 200 HP", 4, 120, "Health", 200),
new Potion("Medium Mana Potion", "Recovery 100 MP", 2, 75, "Mana", 100),
new Potion("Large Health Potion", "Recovery 300 HP", 6, 200, "Health", 300)
}
};
private static Shop[] shops = {
new Shop("Weapon/Armor", items[0]),
new Shop("Potion", items[1])
};

private static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
boolean end = true;
while(end) {
end = select();
}
sc.close();
}

public static boolean select(){
System.out.println("- Shop Select -");
System.out.println(" 1. Weapon/Armor Shop");
System.out.println(" 2. Potion Shop");
System.out.println(" 3. Exit");
System.out.println();
System.out.println("Select : ");
int selection = sc.nextInt();
sc.reset();

if(selection > 3 || selection <= 0){
System.out.println("Invalid number! Try again.");
return true;
}
else if(selection <= 2){
shops[selection - 1].showItemList();
return true;
}
return false;
}
}
30 changes: 30 additions & 0 deletions Solutions/whiteWeed/Game Shop/3/Weapon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Weapon
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 29.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Weapon extends Item {
private int damage;

public Weapon(String name, String description, int weight, int value, int damage){
super(name, description, weight, value);
this.damage = damage;
}

public void describe(){
super.describe();
System.out.println("Damage = " + this.damage);
}
}
30 changes: 30 additions & 0 deletions Solutions/whiteWeed/Game Shop/4/Armor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Armor
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 29.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Armor extends Item { //ㅁㄴㅇㄹ
private int defence;

public Armor(String name, String description, int weight, int value, int defence){
super(name, description, weight, value);
this.defence = defence;
}

public void describe(){
super.describe();
System.out.println("Defence = " + this.defence);
}
}
35 changes: 35 additions & 0 deletions Solutions/whiteWeed/Game Shop/4/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
*/
package whiteWeed.gameShop;

/**
* <pre>
* whiteWeed.gameShop
* |_Item
*
* 1. 개요 :
* 2. 작성일 : 2017. 5. 18.
* </pre>
*
* @author : Weed
* @version : 1.0
*/
public class Item { //ㅁㄴㅇㄹ
protected String name, description;
protected int weight, value;

public Item(String name, String description, int weight, int value){
this.name = name;
this.description = description;
this.weight = weight;
this.value = value;
}

public void describe(){
System.out.println("Name = " + this.name);
System.out.println("Description = " + this.description);
System.out.println("Weight = " + this.weight + " lbs");
System.out.println("Value = " + this.value + " gold coins");
}
}
Loading