1 / 16

Data structures and algorithms CSE - 246 fall 2010 – bs -III term project - monopoly

Data structures and algorithms CSE - 246 fall 2010 – bs -III term project - monopoly. Date Submission: January 29, 2011 Submitted by: Syeda Khushbakth Rizvi Syed Hasan Asghar Submitted to: Ms. Quratul-Ain Nizam - ud -din Rajput. Introduction:.

courtney
Download Presentation

Data structures and algorithms CSE - 246 fall 2010 – bs -III term project - monopoly

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data structures and algorithmsCSE - 246 fall 2010 – bs-III term project - monopoly Date Submission: January 29, 2011 Submitted by: Syeda Khushbakth RizviSyed Hasan AsgharSubmitted to:Ms. Quratul-AinNizam-ud-din Rajput

  2. Introduction: • Monopoly is a board game published by Parker Brothers, a subsidiary of Hasbro. The game is named after the economic concept of monopoly, the domination of a market by a single entity. • The Monopoly game board consists of forty spaces containing twenty-eight properties (twenty-two colored streets, four railroads and two utilities), three Chance spaces, three Community Chest spaces, a Luxury Tax space, an Income Tax space, and the four corner squares: GO, Jail, Free Parking, and Go to Jail.

  3. Goals and learning: • Goal of the game: • Is to bankrupt the opponent as soon as possible, via rents and mortgage. • Goal of the project: • To use the data structures learned during the course and implement them efficiently. • To make use of techniques of GUI. • To create a two player game, played against bot.

  4. Scope and limitations: • SCOPE: • The game makes use of three operations only, out of many which are originally used: Buy, rent and pay taxes. • LIMITATIONS: • The game doesn’t have an ending message, as it is logically deduced that when the opponents cash is finished or have a negative balance the counter-part wins. • There are no houses in estates and rents are doubled when all the properties of a particular color is monopolized. • Mortgages are not included in the game operations. • Banks are not included either.

  5. Programming Tools: • Data structures : • Arrays • Built-in class: • AWT • Action Listener • Action Event • Buffered Image • Swing • Button • Panel • Label • Frame • Text tool

  6. Algorithm: • In start, human plays first. On click of dice roll, piece will move. Roll dice uses random number generator. Movement is done by Cartesian coordinate system. For each estate, either estate can be rented or bought when clicked on buy. When clicked on done the turn ends. Similarly, Bot will play. • Options are available for the players if they want to buy an estate or pay rent and move on. These messages are displayed in the frames and labels. • The estates on the game board are pictures, whose particulars are saved in arrays’ index. When a particular piece lands on a estate, that particular array index is retrieved, and its elements manipulated. • If you get on community chest or chance, changes in the money or location will come about accordingly. • If you get in jail, 50 units of money is detected and the location is reverted 20 places. . If the money is not available, the game ends.

  7. Algorithm: contd.. • The money is deduced according to the choices made by the player. • This also depends on the chance cards and community chest cards which are awarded randomly. • Rents are added or deducted on the next dice roll. • If a player’s money is finished, they lose.

  8. Interface: • Nine classes are made to implement the game efficiently. • Public class Chancearray{} • Public class communitychestarray{} • Public class Estates{} • Public class Monopoly{} • Public class Player{} • Public class whichplayer{} • Public class Boardestate{} • Public class cardsobject{}

  9. Methods implemented: • public static void fillimagearray() • public Monopoly() // handles GUI operations • public void paint(Graphics g) // marks bought estates • public void draw(Graphics g) throws InterruptedException // makes images of estates on the game board • public static int move() // move human’s piece • public static int move1() // moves bot’s piece • public static intinjail(int x, Player p) // calculate jail penalty • public intchecklast(int location, Player p) // gets last position of piece • public static void checkwin(Player p,Playerip) throws InterruptedException // checks if a player is winning yet

  10. Methods implemented: contd.. • public static void checkestate(int move, Player p) // see if estate is available • public static booleanchecklabel(int x) • public static void humanmove() throws InterruptedException • public static void computermove() throws InterruptedException • public static void gettingchance(Player p) // gives chance card • public static void gettingcommunitychest(Player p) // gives community card • public static void main(String args[]) throws Exception • public void setxy() // initialize coordinates • Public intgetx(int x) // retrieves value of x coordinate • Public intgety(int x) // retrieves value of y coordinate • public Player(intp,String n)

  11. Methods implemented: contd.. • public Estates() • public void setcc() • public void getcc(int x, Player p) • public communitychestarray() • public void setchance() • public void getchance(intx,Player p) • public Chancearray() • public cardsobject() • public void setvalue() • public Boardestate()

  12. Screenshots: The layout of game board

  13. Human’s turn screenshot:

  14. Computer’s turn screenshot:

  15. Community chest:

  16. Chance card:

More Related