-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from gal11002/Gavin-L
Gavin l
- Loading branch information
Showing
16 changed files
with
1,119 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ClassDiagram> | ||
<Class name="model.Player" x="873" y="252"> | ||
<AttributesDisplayFilter public-accepted="true" | ||
private-accepted="true" protected-accepted="true" | ||
default-accepted="true" static-accepted="false"/> | ||
<MethodDisplayFilter public-accepted="true" | ||
private-accepted="false" protected-accepted="false" | ||
default-accepted="false" static-accepted="false" | ||
accessors-accepted="false" constructors-accepted="false"/> | ||
<Association destinationClassName="model.Item" | ||
endpointName="_playerInventory" kind="Simple"/> | ||
</Class> | ||
<Class name="controller.RPGame" x="598" y="68"> | ||
<AttributesDisplayFilter public-accepted="true" | ||
private-accepted="true" protected-accepted="true" | ||
default-accepted="true" static-accepted="false"/> | ||
<MethodDisplayFilter public-accepted="true" | ||
private-accepted="false" protected-accepted="false" | ||
default-accepted="false" static-accepted="false" | ||
accessors-accepted="false" constructors-accepted="false"/> | ||
</Class> | ||
<Class name="model.Item" x="635" y="566"> | ||
<AttributesDisplayFilter public-accepted="true" | ||
private-accepted="true" protected-accepted="true" | ||
default-accepted="true" static-accepted="false"/> | ||
<MethodDisplayFilter public-accepted="true" | ||
private-accepted="false" protected-accepted="false" | ||
default-accepted="false" static-accepted="false" | ||
accessors-accepted="false" constructors-accepted="false"/> | ||
</Class> | ||
<Class name="model.Merchant" x="375" y="243"> | ||
<AttributesDisplayFilter public-accepted="true" | ||
private-accepted="true" protected-accepted="true" | ||
default-accepted="true" static-accepted="false"/> | ||
<MethodDisplayFilter public-accepted="true" | ||
private-accepted="false" protected-accepted="false" | ||
default-accepted="false" static-accepted="false" | ||
accessors-accepted="false" constructors-accepted="false"/> | ||
<Association destinationClassName="model.Item" | ||
endpointName="_merchantInventory" kind="Simple"/> | ||
<Communication destinationClassName="model.Item"/> | ||
</Class> | ||
</ClassDiagram> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package controller; | ||
|
||
import exceptions.NotInInventoryException; | ||
import view.TransactionUI; | ||
import model.Item; | ||
import model.Merchant; | ||
import model.Player; | ||
|
||
public class Transaction | ||
{ | ||
private Player _player; | ||
private Merchant _targetMerchant; | ||
private TransactionUI _window; | ||
|
||
public Transaction(Player player, Merchant targetMerchant) | ||
{ | ||
_player = player; | ||
_targetMerchant = targetMerchant; | ||
_window = new TransactionUI(this); | ||
_window.setVisible(true); | ||
} | ||
|
||
/** | ||
* Will be Transaction class's main method | ||
* incomplete method | ||
*/ | ||
public void runTransaction() | ||
{ | ||
} | ||
|
||
/** | ||
* This method invokes the related buy methods and checks in the Player and Merchant classes | ||
* | ||
* @param itemName name of the item | ||
* @param amount amount that the player wants to buy | ||
* @return returns true if transaction successful, false otherwise | ||
*/ | ||
public boolean actionBuy(String itemName, int amount) | ||
{ | ||
if(_player.buy(itemName, _targetMerchant, amount)) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
/** | ||
* This method invokes the related sell methods and checks in the Player and Merchant classes | ||
* | ||
* @param itemName name of the item | ||
* @param amount amount that the player wants to buy | ||
* @return returns true if transaction successful, false otherwise | ||
* @throws NotInInventoryException | ||
*/ | ||
public boolean actionSell(String itemName, int amount) throws NotInInventoryException | ||
{ | ||
if(_player.sell(itemName, _targetMerchant, amount)) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
/** | ||
* This method will push a true up to the class calling it | ||
* incomplete method | ||
* @return returns true | ||
*/ | ||
public boolean actionCancel() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Searches the player inventory for the item matching the item name | ||
* @param itemName name of the item | ||
* @return returns the item with the corresponding name | ||
*/ | ||
public Item searchPlayerInventory(String itemName) | ||
{ | ||
return _player.getItem(itemName); | ||
} | ||
|
||
/** | ||
* Searches the merchant's inventory for the item matching the item name | ||
* @param itemName name of the item | ||
* @return returns item with the corresponding name | ||
*/ | ||
public Item searchMerchantInventory(String itemName) | ||
{ | ||
return _targetMerchant.getItem(itemName); | ||
} | ||
|
||
/** | ||
* Returns the player in transaction | ||
* @return returns the player | ||
*/ | ||
public Player getPlayer() | ||
{ | ||
return _player; | ||
} | ||
|
||
/** | ||
* Returns the merchant in transaction | ||
* @return returns the merchant | ||
*/ | ||
public Merchant getTargetMerchant() | ||
{ | ||
return _targetMerchant; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
MerchantRPGCSE2102/src/exceptions/NotInInventoryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package exceptions; | ||
|
||
@SuppressWarnings("serial") | ||
public class NotInInventoryException extends Exception | ||
{ | ||
public NotInInventoryException() | ||
{ | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package graph; | ||
|
||
|
||
public class Edge { | ||
private Vertex _v; | ||
private Vertex _w; | ||
|
||
|
||
public Vertex getV() { | ||
return _v; | ||
} | ||
|
||
public void setV(Vertex v) { | ||
_v = v; | ||
} | ||
|
||
public Vertex getW() { | ||
return _w; | ||
} | ||
|
||
public void setW(Vertex w) { | ||
_w = w; | ||
} | ||
|
||
public Vertex opposite(Vertex v) { | ||
if (v == _v) | ||
return _w; | ||
else if (v == _w) | ||
return _v; | ||
return null; | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.