Zleef’s Blog

I wish i was swimming here –but instead, i’ll happily work on my computer science homework…

HW 6

So I was really busy doing a serious update of the game, and wasn’t able to implement both the visitor pattern and state pattern. You can see the “planning documents below (sorry it formats it so weird on here, i’ll attach a pdf document for easier viewing) to see where i’m going with this. I really just needed more foundation for the game play. 

The visitor pattern is used for printing out a specially formated list of the ingredients in a specific soup. 

The state pattern will get added soon. What my initial plan for it is to use as a “game state” for displaying different menus depending on if we’re in the start scree, settings, or gameplay, etc…

I’m having a bit of trouble in the Preference class. Basically what i want to happen is when a customer is created they’ll get an instance of Preferences. When the preferences object is created i want it to go and look at all the ingredients that are used in the store (i.e. for a polymorphic approach i’d like it to – in the future, be able to have a number of soups created each with various ingredients. (side note on a side note: i’d like each ingredient to implement a set of “tastes” or something so that you could create additional ingredients and then from the interface there’d be a couple of things that you’d rate the ingredient on for example it might be like salty, sweet, savory, filling, healthy, tasty or something like that and then each ingredient would really only be an object that contained different values for each one of those). When the soup was added to the store, there would be a scan of the soup to see if there are any ingredients used in this soup that haven’t been used before, and if so add them to our list of supplies (store.Supplies) ). and then create a random number between 0 and 100 to use as its preference for this ingredient (i.e. how much it likes that ingredient) later in the game i’ll determine if the customer likes the soup by testing if the amount of the ingredient in the soup is within range of  their preference. The way i’m setting this up is by using ai.Preferences.setPreferences() which will take in a list of all the supplies (ingredients used in the store) and then put them as the key in a hashmap along with a random int between 1 and 100 (which will be there actual preference). Where the actual problem is happening is when i go to get a preference (ai.Preferences.getPreference() ) it’s throwing errros about how it can’t be cast into an int. 

I know this is kind of a belligerent explanation of the problem, but if you can make sense of it and offer any suggestions that’d be great. Thanks!

Advertisement

2 Comments»

  danielmundra wrote @

Your project outline looks good.

For the preferences part, I need to sit down with you and work through the errors, its hard for me to reconstruct it correctly come to either mine or other gtfs office hours.

After that if you can fix and get the patterns in you can email me your project.

Good explanation about the project.

  danielmundra wrote @

Your final looked good, nice use of the patterns.

You did not provide the background.jpg image file so it threw an error, don’t worry about it I did not take out points.

Good luck on your final.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.