This site requires JavaScript, please enable it in your browser!
Greenfoot back
GrimCreeper312
GrimCreeper312 wrote ...

2013/3/23

Store

GrimCreeper312 GrimCreeper312

2013/3/23

#
What would be the best way to make a store
danpost danpost

2013/3/23

#
A store: as in a place for your character to purchase items at, using a monetary or bartering system?
GrimCreeper312 GrimCreeper312

2013/3/23

#
yes they are going to be using money that they collect throughout the game
danpost danpost

2013/3/23

#
You can go one of two main ways: one is to have a new world to perform the exchanging; the other is to use an actor for the store to allow the exchanging in. Either way you will probably need an abstract object class for your inventories; you will create two instances of that class -- one for the store and one for the character. The character can 'carry' its inventory with it in an object inventory field the store will have its also in an object inventory field in whatever class type you use. The inventory data should be stored in arrayList objects and each type object must have a 'price', 'cost' or 'value' field. It may be easier to have all object types that can be bought or sold as a subclass of 'Item', which in turn is a subclass of Actor. Put the 'price' field in the Item class so that all objects of all its subclasses will have a price field, as well as making it easy to limit the type of objects that can be listed in the inventories (by making the arrayLists only able to hold 'Item' objects). You can also have a String field for the name of the item and possibly even another String field for the description of the item. You may even add a 'refund' amount which could be less than the 'price' of the item. You will then need a way to display the inventories, which would include the name of the items, the inventory count of that item, and the cost for one of that item. One actor class can be created to display panels showing the data for one type item. You may decide to create another inventory instance for a shopping cart. How you go about performing the exchanges is up you. You could go the direct route, 'select' the item and then click a directional button to transfer the item from one inventory to the other; or you could go the indirect route: click on item to add to cart (click on cart item to put back) and then click a 'purchase' button to put the items in the players inventory and subtract the monies from the players holdings. I hope I was able to explain what would need to be done clearly; and it is not something I would suggest a beginner to try; but, if you are up for the challenge, go for it!
You need to login to post a reply.