16
Date Submission: January 29, 2011 Submitted by: Syeda Khushbakth Rizvi Syed Hasan Asghar Submitted to: Ms. Quratul-Ain Nizam-ud-din Rajput 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

Embed Size (px)

DESCRIPTION

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:. - PowerPoint PPT Presentation

Citation preview

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

Date Submission: January 29, 2011Submitted by:

Syeda Khushbakth RizviSyed Hasan Asghar

Submitted to:Ms. Quratul-Ain Nizam-ud-din Rajput

DATA STRUCTURES AND ALGORITHMSCSE - 246

FALL 2010 – BS-III TERM PROJECT - MONOPOLY

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

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.

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

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.

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

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.

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

PROGRAMMING TOOLS:o Data structures :

• Arrayso Built-in class:

• AWT1. Action Listener2. Action Event3. Buffered Image

• Swing1. Button2. Panel3. Label4. Frame

o Text tool

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

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.

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

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.

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

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{}

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

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 int injail(int x, Player p) // calculate

jail penalty • public int checklast(int location, Player p) // gets

last position of piece• public static void checkwin(Player p,Player ip)

throws InterruptedException // checks if a player is winning yet

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

METHODS IMPLEMENTED: CONTD..• public static void checkestate(int move, Player p) //

see if estate is available • public static boolean checklabel(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 int getx(int x) // retrieves value of x coordinate • Public int gety(int x) // retrieves value of y coordinate• public Player(int p,String n)

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

METHODS IMPLEMENTED: CONTD..• public Estates()• public void setcc()• public void getcc(int x, Player p)• public communitychestarray()• public void setchance()• public void getchance(int x,Player p)• public Chancearray()• public cardsobject()• public void setvalue()• public Boardestate()

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

Screenshots: The layout of game

board

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

Human’s turn screenshot:

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

Computer’s turn screenshot:

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

Community chest:

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

Chance card: