Saturday, February 14, 2015

Week #6: Summary of Object-Oriented Programming concepts

Week #6: Summary of Object-Oriented Programming concepts


So now I want do a summary of O-O programming.In Wikipedia and our lecture, It is defined as a programming paradigm based on the concept of 'object', which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. In python it is class-based, meaning that objects are instances of classes, which typically also determined their type. We use the object-oriented programming while dealing with a specific situation in our lives. 

One of the most important concepts is ADT (Abstract Data Types), i.e. creating our own type by implementing classes. ADT helps us to specify the intended meaning stored in the data, and the operations it provides in the data. In python, we use classes to specify that kind of data. Attributes and behaviors are the important part of a class. We implement the class by methods of __init__,  __str__,  __repr__ and so on. 



Just like what we do in assignment 1-- creating a class representing a game state when we play a simple game, a class representing a move made by a player, and a class representing a strategy the computer use to fight with players. By doing so, we can just create a game view class to do the work running the game, by dealing with each game state by prompting the player to enter their move or using the strategy the computer use to make a move. During the work of assignment, we need to find how to take moves and how to do the move to the state, for when the computer use the strategy we set, it need to know what moves it can take and when running the game, we need to know how to change the state. To solve the problem, we need to write the method 'possible next moves' and 'change the current state to next state', which is used to find what moves can we do in the current state and after the move what will the next state be. When doing the possible next moves, we are just to find the square that is less than the current value. When doing the change state, we are just to change the player to the opponent and make move to the current value, that is subtract the move to the value. And also, we need to judge whether either player is win when a new state come out. In the subtract square game, to judge the game over state is quite easy. We just need to make sure whether the square is 0.

Recommend:http://computersciencemaggie.blogspot.ca/2015/03/summary-of-object-oriented-programming.html?showComment=1428298896513 
This is a quite specific and comprehensive and thorough explanation of O-O programming. Good slog to review and comprehend the concepts.

To see slog week 3-8 http://148wuboyangw3.blogspot.ca/search?updated-max=2015-03-08T22:46:00-07:00&max-results=7

No comments:

Post a Comment