6
CHESS PROGRAM CHESS PROGRAM CS 85 PHP Programming CS 85 PHP Programming Kristal McKinstry Kristal McKinstry Diana Thai Diana Thai Khalifa Sangarie Khalifa Sangarie Sasan Shaye Sasan Shaye

CHESS PROGRAM

Embed Size (px)

DESCRIPTION

CHESS PROGRAM. CS 85 PHP Programming Kristal McKinstry Diana Thai Khalifa Sangarie Sasan Shaye. Presentation Outline. Object Oriented Programming 1 Min Chess Game Demo 1 Min How Chess Program Works: 3 Min Khalifa: How Program Works Sasan: Database - PowerPoint PPT Presentation

Citation preview

Page 1: CHESS PROGRAM

CHESS PROGRAM CHESS PROGRAM CS 85 PHP ProgrammingCS 85 PHP Programming

Kristal McKinstryKristal McKinstryDiana ThaiDiana Thai

Khalifa SangarieKhalifa SangarieSasan ShayeSasan Shaye

Page 2: CHESS PROGRAM

Presentation OutlinePresentation Outline

• Object Oriented Programming 1 MinObject Oriented Programming 1 Min

• Chess Game DemoChess Game Demo 1 Min 1 Min

• How Chess Program Works: 3 MinHow Chess Program Works: 3 Min

Khalifa: How Program WorksKhalifa: How Program Works

Sasan: DatabaseSasan: Database

• Ask 2 Questions: Ask 2 Questions: 1 Min1 Min

Page 3: CHESS PROGRAM

Object Oriented Object Oriented ProgrammingProgramming

• OUR CHESS PROGRAM uses the OOP method. OUR CHESS PROGRAM uses the OOP method.

• LOWER COSTS:LOWER COSTS: One of the main advantages of OO programming is its ease of One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system thereby modification; objects can easily be modified and added to a system thereby reducing maintenance costs. reducing maintenance costs.

• MODELS THE REAL WORLD:MODELS THE REAL WORLD: OO programming is also considered to be better at OO programming is also considered to be better at modeling the real world than is procedural programming. Applicable concept. modeling the real world than is procedural programming. Applicable concept.

• SOPHISTICATION:SOPHISTICATION: It allows for more complicated and flexible interactions. It allows for more complicated and flexible interactions.

• EASY TO UNDERSTAND:EASY TO UNDERSTAND: OO systems are also easier for non-technical personnel OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition enhancement of a system because it appeals to natural human cognition patterns.patterns.

• LESS TIME:LESS TIME: For some systems, an OO approach can speed development time For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system. purchased and easily modified for a specific system.

Page 4: CHESS PROGRAM

3 “Greatness” About 3 “Greatness” About OOP OOP • Inheritance Inheritance – Instead of starting from scratch, you can easily – Instead of starting from scratch, you can easily

create new objects from existing classes that were built by other create new objects from existing classes that were built by other programmers. This allows reuse of existing code with little or no programmers. This allows reuse of existing code with little or no modification, saving time and money. modification, saving time and money.

• PolymorphismPolymorphism - Even though classes are derived or inherited from - Even though classes are derived or inherited from the same parent class, each derived class or child will have its the same parent class, each derived class or child will have its own behavior. Analogy is that even though Andre Agassi and Steffi own behavior. Analogy is that even though Andre Agassi and Steffi Graff are the parents, their child could inherit their forehand and Graff are the parents, their child could inherit their forehand and backhand moves but plays ping pong. backhand moves but plays ping pong.

• Encapsulation Encapsulation – Hides the objects’ data and methods from the rest – Hides the objects’ data and methods from the rest of the world. The reason why this is great is that when design of the world. The reason why this is great is that when design decisions in a computer program that are most likely to change, decisions in a computer program that are most likely to change, this protects other parts of the program from change if the design this protects other parts of the program from change if the design decision is changed. decision is changed.

Page 5: CHESS PROGRAM

OCollectFormVars

MySQLDatabase

CHESS.PHP ISDECISION MAKER

CHESS.PHP DOES:

(1) Loads Libraries – 1st 15 lines

(2) Instantiates Objects:

(1) OBJ to Build GUI

(2) OBJ to Connect MySQL

(3) OBJ for AIM Chat Feature

(4) OBJ to Test Legal Chess Moves, and A LOT MORE…

(3) Reads the variables from OCollectFormVars and determines how to execute.

DATABASE DOES:

• Retrieve who’s turn

• Stores game details

• Store snapshot of game board after

each legal move & MORE

OCOLLECTFORMVARS DOES:

(1) Interprets user activity and variables & sends data, which CHESS.PHP reads to determine WHAT TO DO.

(2) Uses 2 Arrays:

I. Array 1 collects user information & variables to send to CHESS.PHP

II. Array2 gives data to CHESS.PHP to build GUI.

HOW THE CHESS PROGRAM WORKS:

Page 6: CHESS PROGRAM

How Objects Connect to How Objects Connect to MySQL MySQL

MySQL Database

OServer Object: Connects

To Database

OGame Object

Stores and Retrieves Snapshot of Game Board in MySQL after

every legal move.

OCollect Object:

Its OCollectformVars calls to MySQL to

retrieve user ID & game ID, WHO’S TURN IT IS, findsAvailable partners, ETC.

OStorage Object:

Stores important game details, such as Username And Game IDs, and

Chat Messages