Browse Source

Splitted READMEs

root 8 years ago
parent
commit
a5557266e2
3 changed files with 358 additions and 358 deletions
  1. 160
    0
      README-en.md
  2. 196
    0
      README-es.md
  3. 2
    358
      README.md

+ 160
- 0
README-en.md View File

@@ -0,0 +1,160 @@
1
+
2
+# Classes - Basketball
3
+
4
+
5
+![main1.png](images/main1.png)
6
+![main2.png](images/main2.png)
7
+![main3.png](images/main3.png)
8
+
9
+
10
+*Object Oriented Programming* (OOP) is a programming paradigm that promotes the design of programs by having different objects interacting together to solve a problem. C++ is one of the programming languages that promotes object oriented programming, allowing programmers to create their own classes from scratch or derive them from other existing classes. Other languages that promote OOP are Java, Python, Javascript and PHP.
11
+
12
+In OOP, each object encapsulates within itself certain properties about the entity being modeled (for example, an object that models a *point* encapsulates the coordinates *x* and *y* of the point being represented). Furthermore, each object allows certain actions to be carried out on itself with the  *methods* that the object contains. For example, an object of class *point* could carry out the action of changing the value of the *x* coordinate.
13
+
14
+When an object class we need to use in our program has not been predefined in a library, we need to declare and implement our own class. To do this, we define *classes* that contain data with certain *properties* or *attributes* and actions that we want to carry out with this data through the use of *methods* or *member functions*. This way, we can organize the information and processes in *objects* that have the properties and methods of a class. In today's laboratory experience you will practice defining a class and implementing some of its methods by completing a program that simulates a basketball game between two players, maintaining the score for the game and the global statistics for the two players.
15
+
16
+##Objectives:
17
+
18
+1. Design and define a class.
19
+
20
+2. Implement methods for a class.
21
+
22
+
23
+##Pre-Lab:
24
+
25
+Before coming to the laboratory you should have:
26
+
27
+
28
+1. Reviewed the concepts related to classes and objects.
29
+
30
+2. Studied the skeleton for the program in `main.cpp`.
31
+
32
+3. Studied the concepts and instructions for the laboratory session.
33
+
34
+4. Taken the Pre-Lab quiz that can be found in Moodle.
35
+
36
+---
37
+
38
+---
39
+
40
+##The Game
41
+
42
+The skeleton for the program that we provide simulates a basketball game between two players. The successful throws into the basket receive two points. The data is initiated with the name of each player and the global statistics in the "tournament": total of games played, attempted throws, successful throws and rebounds. The program includes random functions and formulas to determine the player that attempts a throw, if the player scores, and  the player that takes the rebound. During the simulated game the score for each player is kept and each player's data is updated. At the end of the game, a table with the statistics is displayed.
43
+
44
+---
45
+
46
+###The `BBPlayer` Class
47
+
48
+For this laboratory experience, you will define the `BBPlayer` class that contains the attributes and methods that are described below. Since some of the functions that are already defined in the provided code use attributes and methods of this class, it is important that you use the same names that we indicate. The commented code in the `main` function and in `test_BBPlayer` will help you determine the type of data the method should return, the types the parameters should have, and the order in which they are included in the function declaration.
49
+
50
+
51
+####Attributes
52
+
53
+* `_name`: stores the name of the player
54
+* `_shotsTaken`: stores the number of attempted throws during the tournament
55
+* `_showsMade`: stores the number of throws scored during the tournament
56
+* `_gamesPlayed`: stores the number of games played during the tournament
57
+* `_rebounds`: stores the number of rebounds during the tournament
58
+* `_score`: stores the player's score during the game
59
+
60
+
61
+####Methods
62
+
63
+* default constructor. *(method included in `main.cpp`)*
64
+* `setAll()`: methods that assigns an initial value to all of the attributes of the object. Notice that this method is invoked at the beginning of `main` to assign initial values to the array `P` that is an array of two objects of the `BBPlayer` class.
65
+* `name()`: method to acquire the name of the player.
66
+* `shotPercentage()`: method to compute the percent of throws scored; is used to determine if the attempted throw is scored by a player. *(method included in `main.cpp`)*
67
+* `reboundsPerGame()`: method to compute the average number of rebounds caught by a player; is used to determine if the player successfully catches the rebound. *(method included in `main.cpp`)*
68
+* 'shotMade()': method that registers that a shot was scored, that a shot was attempted, and updates the score for the player.
69
+* `shotMissed()`: method that registers an attempted throw (but unsuccessful).
70
+* `reboundMade()`: method that registers that a rebound was caught.
71
+* `addGame()`: method that registers that a game was played.
72
+* `score()`: method to acquire the score of a player.
73
+* `printStats()`: method that displays a player's statistics. *(method included in `main.cpp`)*
74
+
75
+---
76
+
77
+---
78
+
79
+!INCLUDE "../../eip-diagnostic/basket/en/diag-basket-01.html"
80
+!INCLUDE "../../eip-diagnostic/basket/en/diag-basket-02.html"
81
+
82
+---
83
+
84
+---
85
+
86
+##Laboratory Session:
87
+
88
+During this laboratory session, your task will be to define the `BBPlayer` class with the attributes and method prototypes listed above. The skeleton for the program includes the code to define some of the methods; others will have to be defined.
89
+
90
+The skeleton for the program also includes the `test_BBPlayer` function that does unit tests to each of the functions in the program. The tests are commented and, as you define each function, you will remove the comment, test and modify the function, until the test for that function is passed. Once all of the functions are ready and have passed the tests, the whole program is tested by removing the necessary comments in the `main` function.
91
+
92
+
93
+###Exercise 0: Download and understand the provided code
94
+
95
+####Instructions
96
+
97
+1. Load the `basket01` project onto Qt by double clicking on the `basket01.pro` filein the directory `Documents/eip/Classes-Basket` of your computer. You may also go to `http://bitbucket.org/eip-uprrp/classes-basket` to download the `Classes-Basket` folder to your computer.
98
+
99
+2. This program will run on the terminal and you should select this option from the "Projects" window. To access this window, you select "Projects" in the vertical menu to the left. Afterwards, in `Build & Run` you select `Run` and then mark the box that says `Run in terminal`.
100
+
101
+3. Study and understand the code in the `main.cpp` file, including the code that is commented.
102
+
103
+###Exercise 1: Define the `BBPlayer` class
104
+
105
+1. Define the `BBPlayer` class with the specifications included above. For each one of the methods that are specified above:
106
+
107
+    a. Include a prototype for the method in the class definition.
108
+
109
+    b. If the corresponding member function is already coded in the program, remove the comments from the corresponding sections for this function in `test_BBPlayer`.
110
+
111
+    c. If the corresponding member function is not coded, define the function and then remove the comments from the corresponding sections for this function in `test_BBPlayer`.
112
+
113
+    d. Run the program and verify that it passed all of the tests. You should obtain a window similar to the one in Figure 1. If your code does not pass all the tests, revise your code. Repeat until your code has passed all of the tests.
114
+
115
+    ---
116
+
117
+    ![figure1.png](images/figure1.png)
118
+
119
+    **Figure 1.** Example of the window you should obtain if the code passes the unit tests.
120
+
121
+    ---
122
+
123
+2. Once you have all of the functions defined and tested, uncomment the code in the `main` function to test the whole program. If the program functions correctly, you should obtain a window that starts similarly to the one in Figure 2 and finishes like the one in Figure 3.
124
+
125
+    ---
126
+
127
+    ![figure2.png](images/figure2.png)
128
+
129
+
130
+    **Figure 2.** Example of the start of the window you should obtain if the program functions correctly.
131
+
132
+    ---
133
+
134
+    ![figure3.png](images/figure3.png)
135
+
136
+    **Figure 3.** Example of the window you should obtain at the end of the program if it is working correctly.
137
+
138
+    ---
139
+
140
+**IMPORTANT:** You SHOULD NOT make any changes in the `main` and `test_BBPlayer` functions, aside from removing the comments.
141
+
142
+---
143
+
144
+---
145
+
146
+##Deliverables
147
+
148
+Use "Deliverables" in Moodle to hand in the `main.cpp` file. Remember to use good programming techniques, include the name of the programmers involved, and document your program.
149
+
150
+---
151
+
152
+---
153
+
154
+##References
155
+
156
+[1] http://www.telegraph.co.uk/sport/olympics/basketball/9348826/London-2012-Olympics-Temi-Fagbenle-in-Team-GB-womens-basketball-squad.html
157
+
158
+[2] http://www.musthavemenus.com/category/bar-clipart.html
159
+
160
+[3] http://basketball.isport.com/basketball-guides/finding-your-niche-in-basketball

+ 196
- 0
README-es.md View File

@@ -0,0 +1,196 @@
1
+
2
+# Clases - Baloncesto
3
+
4
+
5
+![main1.png](images/main1.png)
6
+![main2.png](images/main2.png)
7
+![main3.png](images/main3.png)
8
+
9
+[Versión 2016-05-02]
10
+
11
+La *programación orientada a objetos* (object oriented programming, OOP) es un paradigma de programación que promueve el diseño de programas en el que distintos objetos interactúan entre sí para resolver un problema.   C++ es uno de los lenguajes de programación que promueve la programación orientada a objetos, permitiendo que los programadores creen sus propias clases desde cero o derivadas de otras clases existentes. Algunos otros lenguajes que promueven OOP son Java, Python, javascript y PHP.  
12
+
13
+En OOP, cada objeto encapsula dentro de él ciertas propiedades sobre el ente que está modelando (por ejemplo, un objeto que modela un *punto* encapsula dentro de sí las coordenadas *x* y *y* del punto que representa). Además, cada objeto contiene *metodos*, i.e. acciones que puede realizar sobre sus propiedades o sobre otros objetos. Por ejemplo, un objeto de clase *punto* puede realizar la acción de cambiar el valor de su coordenada *x*.
14
+
15
+Cuando la clase de objetos que necesitamos utilizar en nuestro programa no ha sido predefinida en el alguna librería, necesitamos declarar e implementar nuestra propia clase. Para esto definimos *clases* que contengan datos con ciertas *propiedades* o *atributos* y acciones que queremos hacer con esos datos por medio de *métodos* o *funciones miembro*. De esta manera, podremos organizar la información y procesos en *objetos* que tienen las propiedades y métodos de una clase. En la experiencia de laboratorio de hoy practicarás la implementación de una clase y algunos de sus métodos, completando un programa que simula un partido de baloncesto entre dos jugadores, mantiene la puntuación del juego y las estadísticas globales de los dos jugadores.
16
+
17
+
18
+## Objetivos:
19
+
20
+1. Diseñar y definir una clase.
21
+
22
+2. Implementar métodos de una clase.
23
+
24
+
25
+## Pre-Lab:
26
+
27
+Antes de llegar al laboratorio debes haber:
28
+
29
+1. Repasado los conceptos relacionados a clases y objetos.
30
+
31
+2. Estudiado el esqueleto del programa en `main.cpp`.
32
+
33
+3. Estudiado los conceptos e instrucciones para la sesión de laboratorio.
34
+
35
+
36
+
37
+---
38
+
39
+---
40
+
41
+
42
+
43
+## El juego
44
+
45
+El esqueleto de programa que te proveemos simula un partido de baloncesto entre dos jugadores. El programa utiliza OOP y simula el partido creando un objeto de clase BBPlayer para cada jugador e invocando sus métodos. El objeto que representa cada jugador contiene atributos tales como el nombre del jugador y estádisticas de juego, e.g. tiros intentados y anotados. Durante el juego, cada tiro anotado vale dos puntos. El programa incluye funciones  aleatorias y fórmulas para determinar el jugador que intenta el tiro, si anota el tiro y el jugador que coge el rebote.  Durante el partido simulado se mantiene la puntuación de cada jugador y se actualizan los datos para cada jugador. Al final del partido se despliega una tabla con las estadísticas.
46
+
47
+El algoritmo que simula el juego es el siguiente:
48
+
49
+```
50
+1.  inicializar jugadores
51
+2.  asignar jugadorEnOfensiva aleatoriamente
52
+2.  while (ninguno ha ganado):
53
+3.    simular tiro al canasto
54
+4.    if (anotó):
55
+5.      actualizar estadisticas de quien tiró al canasto
56
+6.      if (puntuación >= 32):
57
+7.        informar que jugadorEnOfensiva ganó
58
+8.      else:
59
+9.        intercambiar jugadorEnOfensiva
60
+10.   else:
61
+11.     actualizar estadisticas de quien tiró al canasto
62
+11.     determinar quien atrapa rebote
63
+12.     actualizar estadisticas de quien atrapó rebote
64
+13.     asignar jugadorEnOfensiva
65
+14. mostrar estadísticas de los jugadores
66
+```
67
+
68
+---
69
+
70
+### La clase `BBPlayer`
71
+
72
+Para esta experiencia de laboratorio, definirás una clase `BBPlayer` que contenga los atributos y métodos que se describen a continuación. Como algunas de las funciones que ya están definidas en el código provisto utilizan atributos y métodos de esta clase, es importante que utilices los mismos nombres que te indicamos. El código comentado en la función `main` y en `test_BBPlayer` también te ayudará a determinar el tipo de dato que debe devolver el método y el orden y tipo de sus parámetros.
73
+
74
+#### Atributos
75
+
76
+*  `_name`: guardará el nombre del jugador
77
+*  `_shotsTaken`: guardará el número de tiros al canasto intentados durante el torneo
78
+*  `_shotsMade`: guardará el número de tiros al canasto anotados durante el torneo
79
+*  `_gamesPlayed`: guardará el número de juegos jugados durante el torneo
80
+*  `_rebounds`: guardará el número de rebotes durante el torneo
81
+*  `_score`: guardará la puntuación del jugador durante el partido
82
+
83
+#### Métodos
84
+
85
+* constructor por defecto (default). *(método incluido en `main.cpp`)*
86
+* `setAll()`: método que asigna valor inicial a todos los atributos de un objeto. Nota que este método está invocado al comienzo de `main` para asignarle valores iniciales al arreglo `P` que es un arreglo de dos objetos de la clase `BBPlayer`.
87
+* `name()`: método para adquirir el nombre del jugador.
88
+* `shotPercentage()`: método para calcular el porciento de tiros anotados; durante el juego se usa para determinar si el tiro intentado por un jugador se anota. *(método incluido en `main.cpp`)*
89
+* `reboundsPerGame()`: método para calcular el promedio de rebotes atrapados por juego; durante el juego se usa para determinar cuál de los jugadores atrapa un rebote. *(método incluido en `main.cpp`)*
90
+* `shotMade()`: método que registra que se anotó un tiro, i.e. incrementa _shotsMade, _shotsTaken y el _score del jugador.
91
+* `shotMissed()`: método que registra tiro fallado, i.e. incrementa solo _shotsTaken del jugador.
92
+* `reboundMade()`: método que registra un rebote atrapado.
93
+* `addGame()`: método que registra que se jugó un partido.
94
+* `score()`: método para adquirir la puntuación del jugador.
95
+* `printStats()`: método para desplegar las estádisticas del jugador. *(método incluido en `main.cpp`)*
96
+
97
+---
98
+
99
+---
100
+
101
+
102
+
103
+
104
+!INCLUDE "../../eip-diagnostic/basket/es/diag-basket-01.html"
105
+!INCLUDE "../../eip-diagnostic/basket/es/diag-basket-02.html"
106
+
107
+---
108
+
109
+---
110
+
111
+## Sesión de laboratorio:
112
+
113
+Tu tarea durante la sesión de laboratorio será el definir la clase `BBPlayer` con los atributos y prototipos de los métodos que se listan arriba. El esqueleto del programa incluye la definición de algunos métodos. Tu debes completar el resto.
114
+
115
+El esqueleto del programa también incluye la función `test_BBPlayer` que hace pruebas unitarias a cada una de las funciones del programa. Las pruebas están comentadas y, según vayas definiendo las funciones, debes irlas descomentando, probando y modificando la función  hasta que pase la prueba. Una vez todas las funciones estén listas y hayan pasado las pruebas, probarás el programa completo removiendo los comentarios que sean necesarios en el código de la función `main`.
116
+
117
+
118
+### Ejercicio 0: Bajar y entender el código provisto
119
+
120
+#### Instrucciones
121
+
122
+1. Descarga la carpeta `classes-basket` de `Bitbucket` usando un terminal, moviéndote al directorio `Documents/eip`, y escribiendo el comando `git clone http://bitbucket.org/eip-uprrp/classes-basket`.
123
+
124
+2. Carga a Qt creator el proyecto `basket01`  haciendo doble "click" en el archivo `basket01.pro` que se encuentra en la carpeta  `Documents/eip/classes-basket` de tu computadora.
125
+
126
+3. El ejecutable correrá en el terminal y  debes seleccionar esa opción desde la ventana de "Projects". Para acceder a esta ventana, seleccionas "Projects" en el menú vertical de la izquierda. Luego en `Build & Run` seleccionas `Run` y luego marcas la caja que dice `Run in terminal`.
127
+
128
+4. Estudia el código en el archivo `main.cpp`, incluyendo el código que está comentado.
129
+
130
+### Ejercicio 1: Definir la clase `BBPlayer`
131
+
132
+1. Define la clase `BBPlayer` con las especificaciones que se proveen en la sección **La clase BBPlayer**. Para cada uno de los métodos que se especifican en esa sección:
133
+
134
+    a. Incluye su prototipo en la definición de la clase
135
+
136
+    b. Si el método ya ha sido implementado, remueve los comentarios de las secciones correspondientes a esa función en  `test_BBPlayer`.
137
+
138
+    c. Si el método no ha sido implementado, hazlo y luego remueve los comentarios de las secciones correspondientes a esa función en  `test_BBPlayer`.
139
+
140
+    d. Corre el programa y verifica que haya pasado las pruebas. Debes obtener una ventana similar a la de la Figura 1, i.e. debe contener el mensaje `All unit tests passed!!!` . Si no pasa las pruebas, revisa tu código. Repite hasta que tu código haya pasado todas las pruebas.
141
+
142
+    ---
143
+
144
+    ![figure1.png](images/figure1.png)
145
+
146
+    **Figura 1.** Ejemplo de la pantalla que debes obtener si el código pasa las pruebas unitarias.
147
+
148
+    ---
149
+
150
+2. Una vez tengas todas los métodos definidos y probados, descomenta el código de la función `main` para probar el programa completo. Si el programa funciona correctamente, debes obtener una ventana que comienza de manera similar a la Figura 2 y termina como en la Figura 3.
151
+
152
+    ---
153
+
154
+    ![figure2.png](images/figure2.png)
155
+
156
+    **Figura 2.** Ejemplo del comienzo de la pantalla que debes obtener si el programa funciona correctamente.
157
+
158
+    ---
159
+
160
+    ![figure3.png](images/figure3.png)
161
+
162
+    **Figura 3.** Ejemplo de la pantalla que debes obtener al final del programa si éste funciona correctamente.
163
+
164
+    ---
165
+
166
+**IMPORTANTE:** NO debes hacer ningún cambio en las funciones  `main` y `test_BBPlayer`, aparte de quitar los comentarios.
167
+
168
+---
169
+
170
+---
171
+
172
+## Entrega
173
+
174
+Utiliza "Entrega" en Moodle para entregar el archivo `main.cpp`. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
175
+
176
+
177
+
178
+---
179
+
180
+---
181
+
182
+
183
+## Referencias
184
+
185
+[1] http://www.telegraph.co.uk/sport/olympics/basketball/9348826/London-2012-Olympics-Temi-Fagbenle-in-Team-GB-womens-basketball-squad.html
186
+
187
+[2] http://www.musthavemenus.com/category/bar-clipart.html
188
+
189
+[3] http://basketball.isport.com/basketball-guides/finding-your-niche-in-basketball
190
+
191
+---
192
+
193
+---
194
+
195
+---
196
+

+ 2
- 358
README.md View File

@@ -1,358 +1,2 @@
1
-[English](#markdown-header-classes-basket) | [Español](#markdown-header-clases-baloncesto)
2
-
3
-# Clases - Baloncesto
4
-
5
-
6
-![main1.png](images/main1.png)
7
-![main2.png](images/main2.png)
8
-![main3.png](images/main3.png)
9
-
10
-[Versión 2016-05-02]
11
-
12
-La *programación orientada a objetos* (object oriented programming, OOP) es un paradigma de programación que promueve el diseño de programas en el que distintos objetos interactúan entre sí para resolver un problema.   C++ es uno de los lenguajes de programación que promueve la programación orientada a objetos, permitiendo que los programadores creen sus propias clases desde cero o derivadas de otras clases existentes. Algunos otros lenguajes que promueven OOP son Java, Python, javascript y PHP.  
13
-
14
-En OOP, cada objeto encapsula dentro de él ciertas propiedades sobre el ente que está modelando (por ejemplo, un objeto que modela un *punto* encapsula dentro de sí las coordenadas *x* y *y* del punto que representa). Además, cada objeto contiene *metodos*, i.e. acciones que puede realizar sobre sus propiedades o sobre otros objetos. Por ejemplo, un objeto de clase *punto* puede realizar la acción de cambiar el valor de su coordenada *x*.
15
-
16
-Cuando la clase de objetos que necesitamos utilizar en nuestro programa no ha sido predefinida en el alguna librería, necesitamos declarar e implementar nuestra propia clase. Para esto definimos *clases* que contengan datos con ciertas *propiedades* o *atributos* y acciones que queremos hacer con esos datos por medio de *métodos* o *funciones miembro*. De esta manera, podremos organizar la información y procesos en *objetos* que tienen las propiedades y métodos de una clase. En la experiencia de laboratorio de hoy practicarás la implementación de una clase y algunos de sus métodos, completando un programa que simula un partido de baloncesto entre dos jugadores, mantiene la puntuación del juego y las estadísticas globales de los dos jugadores.
17
-
18
-
19
-## Objetivos:
20
-
21
-1. Diseñar y definir una clase.
22
-
23
-2. Implementar métodos de una clase.
24
-
25
-
26
-## Pre-Lab:
27
-
28
-Antes de llegar al laboratorio debes haber:
29
-
30
-1. Repasado los conceptos relacionados a clases y objetos.
31
-
32
-2. Estudiado el esqueleto del programa en `main.cpp`.
33
-
34
-3. Estudiado los conceptos e instrucciones para la sesión de laboratorio.
35
-
36
-
37
-
38
----
39
-
40
----
41
-
42
-
43
-
44
-## El juego
45
-
46
-El esqueleto de programa que te proveemos simula un partido de baloncesto entre dos jugadores. El programa utiliza OOP y simula el partido creando un objeto de clase BBPlayer para cada jugador e invocando sus métodos. El objeto que representa cada jugador contiene atributos tales como el nombre del jugador y estádisticas de juego, e.g. tiros intentados y anotados. Durante el juego, cada tiro anotado vale dos puntos. El programa incluye funciones  aleatorias y fórmulas para determinar el jugador que intenta el tiro, si anota el tiro y el jugador que coge el rebote.  Durante el partido simulado se mantiene la puntuación de cada jugador y se actualizan los datos para cada jugador. Al final del partido se despliega una tabla con las estadísticas.
47
-
48
-El algoritmo que simula el juego es el siguiente:
49
-
50
-```
51
-1.  inicializar jugadores
52
-2.  asignar jugadorEnOfensiva aleatoriamente
53
-2.  while (ninguno ha ganado):
54
-3.    simular tiro al canasto
55
-4.    if (anotó):
56
-5.      actualizar estadisticas de quien tiró al canasto
57
-6.      if (puntuación >= 32):
58
-7.        informar que jugadorEnOfensiva ganó
59
-8.      else:
60
-9.        intercambiar jugadorEnOfensiva
61
-10.   else:
62
-11.     actualizar estadisticas de quien tiró al canasto
63
-11.     determinar quien atrapa rebote
64
-12.     actualizar estadisticas de quien atrapó rebote
65
-13.     asignar jugadorEnOfensiva
66
-14. mostrar estadísticas de los jugadores
67
-```
68
-
69
----
70
-
71
-### La clase `BBPlayer`
72
-
73
-Para esta experiencia de laboratorio, definirás una clase `BBPlayer` que contenga los atributos y métodos que se describen a continuación. Como algunas de las funciones que ya están definidas en el código provisto utilizan atributos y métodos de esta clase, es importante que utilices los mismos nombres que te indicamos. El código comentado en la función `main` y en `test_BBPlayer` también te ayudará a determinar el tipo de dato que debe devolver el método y el orden y tipo de sus parámetros.
74
-
75
-#### Atributos
76
-
77
-*  `_name`: guardará el nombre del jugador
78
-*  `_shotsTaken`: guardará el número de tiros al canasto intentados durante el torneo
79
-*  `_shotsMade`: guardará el número de tiros al canasto anotados durante el torneo
80
-*  `_gamesPlayed`: guardará el número de juegos jugados durante el torneo
81
-*  `_rebounds`: guardará el número de rebotes durante el torneo
82
-*  `_score`: guardará la puntuación del jugador durante el partido
83
-
84
-#### Métodos
85
-
86
-* constructor por defecto (default). *(método incluido en `main.cpp`)*
87
-* `setAll()`: método que asigna valor inicial a todos los atributos de un objeto. Nota que este método está invocado al comienzo de `main` para asignarle valores iniciales al arreglo `P` que es un arreglo de dos objetos de la clase `BBPlayer`.
88
-* `name()`: método para adquirir el nombre del jugador.
89
-* `shotPercentage()`: método para calcular el porciento de tiros anotados; durante el juego se usa para determinar si el tiro intentado por un jugador se anota. *(método incluido en `main.cpp`)*
90
-* `reboundsPerGame()`: método para calcular el promedio de rebotes atrapados por juego; durante el juego se usa para determinar cuál de los jugadores atrapa un rebote. *(método incluido en `main.cpp`)*
91
-* `shotMade()`: método que registra que se anotó un tiro, i.e. incrementa _shotsMade, _shotsTaken y el _score del jugador.
92
-* `shotMissed()`: método que registra tiro fallado, i.e. incrementa solo _shotsTaken del jugador.
93
-* `reboundMade()`: método que registra un rebote atrapado.
94
-* `addGame()`: método que registra que se jugó un partido.
95
-* `score()`: método para adquirir la puntuación del jugador.
96
-* `printStats()`: método para desplegar las estádisticas del jugador. *(método incluido en `main.cpp`)*
97
-
98
----
99
-
100
----
101
-
102
-
103
-
104
-
105
-!INCLUDE "../../eip-diagnostic/basket/es/diag-basket-01.html"
106
-!INCLUDE "../../eip-diagnostic/basket/es/diag-basket-02.html"
107
-
108
----
109
-
110
----
111
-
112
-## Sesión de laboratorio:
113
-
114
-Tu tarea durante la sesión de laboratorio será el definir la clase `BBPlayer` con los atributos y prototipos de los métodos que se listan arriba. El esqueleto del programa incluye la definición de algunos métodos. Tu debes completar el resto.
115
-
116
-El esqueleto del programa también incluye la función `test_BBPlayer` que hace pruebas unitarias a cada una de las funciones del programa. Las pruebas están comentadas y, según vayas definiendo las funciones, debes irlas descomentando, probando y modificando la función  hasta que pase la prueba. Una vez todas las funciones estén listas y hayan pasado las pruebas, probarás el programa completo removiendo los comentarios que sean necesarios en el código de la función `main`.
117
-
118
-
119
-### Ejercicio 0: Bajar y entender el código provisto
120
-
121
-#### Instrucciones
122
-
123
-1. Descarga la carpeta `classes-basket` de `Bitbucket` usando un terminal, moviéndote al directorio `Documents/eip`, y escribiendo el comando `git clone http://bitbucket.org/eip-uprrp/classes-basket`.
124
-
125
-2. Carga a Qt creator el proyecto `basket01`  haciendo doble "click" en el archivo `basket01.pro` que se encuentra en la carpeta  `Documents/eip/classes-basket` de tu computadora.
126
-
127
-3. El ejecutable correrá en el terminal y  debes seleccionar esa opción desde la ventana de "Projects". Para acceder a esta ventana, seleccionas "Projects" en el menú vertical de la izquierda. Luego en `Build & Run` seleccionas `Run` y luego marcas la caja que dice `Run in terminal`.
128
-
129
-4. Estudia el código en el archivo `main.cpp`, incluyendo el código que está comentado.
130
-
131
-### Ejercicio 1: Definir la clase `BBPlayer`
132
-
133
-1. Define la clase `BBPlayer` con las especificaciones que se proveen en la sección **La clase BBPlayer**. Para cada uno de los métodos que se especifican en esa sección:
134
-
135
-    a. Incluye su prototipo en la definición de la clase
136
-
137
-    b. Si el método ya ha sido implementado, remueve los comentarios de las secciones correspondientes a esa función en  `test_BBPlayer`.
138
-
139
-    c. Si el método no ha sido implementado, hazlo y luego remueve los comentarios de las secciones correspondientes a esa función en  `test_BBPlayer`.
140
-
141
-    d. Corre el programa y verifica que haya pasado las pruebas. Debes obtener una ventana similar a la de la Figura 1, i.e. debe contener el mensaje `All unit tests passed!!!` . Si no pasa las pruebas, revisa tu código. Repite hasta que tu código haya pasado todas las pruebas.
142
-
143
-    ---
144
-
145
-    ![figure1.png](images/figure1.png)
146
-
147
-    **Figura 1.** Ejemplo de la pantalla que debes obtener si el código pasa las pruebas unitarias.
148
-
149
-    ---
150
-
151
-2. Una vez tengas todas los métodos definidos y probados, descomenta el código de la función `main` para probar el programa completo. Si el programa funciona correctamente, debes obtener una ventana que comienza de manera similar a la Figura 2 y termina como en la Figura 3.
152
-
153
-    ---
154
-
155
-    ![figure2.png](images/figure2.png)
156
-
157
-    **Figura 2.** Ejemplo del comienzo de la pantalla que debes obtener si el programa funciona correctamente.
158
-
159
-    ---
160
-
161
-    ![figure3.png](images/figure3.png)
162
-
163
-    **Figura 3.** Ejemplo de la pantalla que debes obtener al final del programa si éste funciona correctamente.
164
-
165
-    ---
166
-
167
-**IMPORTANTE:** NO debes hacer ningún cambio en las funciones  `main` y `test_BBPlayer`, aparte de quitar los comentarios.
168
-
169
----
170
-
171
----
172
-
173
-## Entrega
174
-
175
-Utiliza "Entrega" en Moodle para entregar el archivo `main.cpp`. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
176
-
177
-
178
-
179
----
180
-
181
----
182
-
183
-
184
-## Referencias
185
-
186
-[1] http://www.telegraph.co.uk/sport/olympics/basketball/9348826/London-2012-Olympics-Temi-Fagbenle-in-Team-GB-womens-basketball-squad.html
187
-
188
-[2] http://www.musthavemenus.com/category/bar-clipart.html
189
-
190
-[3] http://basketball.isport.com/basketball-guides/finding-your-niche-in-basketball
191
-
192
----
193
-
194
----
195
-
196
----
197
-
198
-[English](#markdown-header-classes-basket) | [Español](#markdown-header-clases-baloncesto)
199
-
200
-# Classes - Basketball
201
-
202
-
203
-![main1.png](images/main1.png)
204
-![main2.png](images/main2.png)
205
-![main3.png](images/main3.png)
206
-
207
-
208
-*Object Oriented Programming* (OOP) is a programming paradigm that promotes the design of programs by having different objects interacting together to solve a problem. C++ is one of the programming languages that promotes object oriented programming, allowing programmers to create their own classes from scratch or derive them from other existing classes. Other languages that promote OOP are Java, Python, Javascript and PHP.
209
-
210
-In OOP, each object encapsulates within itself certain properties about the entity being modeled (for example, an object that models a *point* encapsulates the coordinates *x* and *y* of the point being represented). Furthermore, each object allows certain actions to be carried out on itself with the  *methods* that the object contains. For example, an object of class *point* could carry out the action of changing the value of the *x* coordinate.
211
-
212
-When an object class we need to use in our program has not been predefined in a library, we need to declare and implement our own class. To do this, we define *classes* that contain data with certain *properties* or *attributes* and actions that we want to carry out with this data through the use of *methods* or *member functions*. This way, we can organize the information and processes in *objects* that have the properties and methods of a class. In today's laboratory experience you will practice defining a class and implementing some of its methods by completing a program that simulates a basketball game between two players, maintaining the score for the game and the global statistics for the two players.
213
-
214
-##Objectives:
215
-
216
-1. Design and define a class.
217
-
218
-2. Implement methods for a class.
219
-
220
-
221
-##Pre-Lab:
222
-
223
-Before coming to the laboratory you should have:
224
-
225
-
226
-1. Reviewed the concepts related to classes and objects.
227
-
228
-2. Studied the skeleton for the program in `main.cpp`.
229
-
230
-3. Studied the concepts and instructions for the laboratory session.
231
-
232
-4. Taken the Pre-Lab quiz that can be found in Moodle.
233
-
234
----
235
-
236
----
237
-
238
-##The Game
239
-
240
-The skeleton for the program that we provide simulates a basketball game between two players. The successful throws into the basket receive two points. The data is initiated with the name of each player and the global statistics in the "tournament": total of games played, attempted throws, successful throws and rebounds. The program includes random functions and formulas to determine the player that attempts a throw, if the player scores, and  the player that takes the rebound. During the simulated game the score for each player is kept and each player's data is updated. At the end of the game, a table with the statistics is displayed.
241
-
242
----
243
-
244
-###The `BBPlayer` Class
245
-
246
-For this laboratory experience, you will define the `BBPlayer` class that contains the attributes and methods that are described below. Since some of the functions that are already defined in the provided code use attributes and methods of this class, it is important that you use the same names that we indicate. The commented code in the `main` function and in `test_BBPlayer` will help you determine the type of data the method should return, the types the parameters should have, and the order in which they are included in the function declaration.
247
-
248
-
249
-####Attributes
250
-
251
-* `_name`: stores the name of the player
252
-* `_shotsTaken`: stores the number of attempted throws during the tournament
253
-* `_showsMade`: stores the number of throws scored during the tournament
254
-* `_gamesPlayed`: stores the number of games played during the tournament
255
-* `_rebounds`: stores the number of rebounds during the tournament
256
-* `_score`: stores the player's score during the game
257
-
258
-
259
-####Methods
260
-
261
-* default constructor. *(method included in `main.cpp`)*
262
-* `setAll()`: methods that assigns an initial value to all of the attributes of the object. Notice that this method is invoked at the beginning of `main` to assign initial values to the array `P` that is an array of two objects of the `BBPlayer` class.
263
-* `name()`: method to acquire the name of the player.
264
-* `shotPercentage()`: method to compute the percent of throws scored; is used to determine if the attempted throw is scored by a player. *(method included in `main.cpp`)*
265
-* `reboundsPerGame()`: method to compute the average number of rebounds caught by a player; is used to determine if the player successfully catches the rebound. *(method included in `main.cpp`)*
266
-* 'shotMade()': method that registers that a shot was scored, that a shot was attempted, and updates the score for the player.
267
-* `shotMissed()`: method that registers an attempted throw (but unsuccessful).
268
-* `reboundMade()`: method that registers that a rebound was caught.
269
-* `addGame()`: method that registers that a game was played.
270
-* `score()`: method to acquire the score of a player.
271
-* `printStats()`: method that displays a player's statistics. *(method included in `main.cpp`)*
272
-
273
----
274
-
275
----
276
-
277
-!INCLUDE "../../eip-diagnostic/basket/en/diag-basket-01.html"
278
-!INCLUDE "../../eip-diagnostic/basket/en/diag-basket-02.html"
279
-
280
----
281
-
282
----
283
-
284
-##Laboratory Session:
285
-
286
-During this laboratory session, your task will be to define the `BBPlayer` class with the attributes and method prototypes listed above. The skeleton for the program includes the code to define some of the methods; others will have to be defined.
287
-
288
-The skeleton for the program also includes the `test_BBPlayer` function that does unit tests to each of the functions in the program. The tests are commented and, as you define each function, you will remove the comment, test and modify the function, until the test for that function is passed. Once all of the functions are ready and have passed the tests, the whole program is tested by removing the necessary comments in the `main` function.
289
-
290
-
291
-###Exercise 0: Download and understand the provided code
292
-
293
-####Instructions
294
-
295
-1. Load the `basket01` project onto Qt by double clicking on the `basket01.pro` filein the directory `Documents/eip/Classes-Basket` of your computer. You may also go to `http://bitbucket.org/eip-uprrp/classes-basket` to download the `Classes-Basket` folder to your computer.
296
-
297
-2. This program will run on the terminal and you should select this option from the "Projects" window. To access this window, you select "Projects" in the vertical menu to the left. Afterwards, in `Build & Run` you select `Run` and then mark the box that says `Run in terminal`.
298
-
299
-3. Study and understand the code in the `main.cpp` file, including the code that is commented.
300
-
301
-###Exercise 1: Define the `BBPlayer` class
302
-
303
-1. Define the `BBPlayer` class with the specifications included above. For each one of the methods that are specified above:
304
-
305
-    a. Include a prototype for the method in the class definition.
306
-
307
-    b. If the corresponding member function is already coded in the program, remove the comments from the corresponding sections for this function in `test_BBPlayer`.
308
-
309
-    c. If the corresponding member function is not coded, define the function and then remove the comments from the corresponding sections for this function in `test_BBPlayer`.
310
-
311
-    d. Run the program and verify that it passed all of the tests. You should obtain a window similar to the one in Figure 1. If your code does not pass all the tests, revise your code. Repeat until your code has passed all of the tests.
312
-
313
-    ---
314
-
315
-    ![figure1.png](images/figure1.png)
316
-
317
-    **Figure 1.** Example of the window you should obtain if the code passes the unit tests.
318
-
319
-    ---
320
-
321
-2. Once you have all of the functions defined and tested, uncomment the code in the `main` function to test the whole program. If the program functions correctly, you should obtain a window that starts similarly to the one in Figure 2 and finishes like the one in Figure 3.
322
-
323
-    ---
324
-
325
-    ![figure2.png](images/figure2.png)
326
-
327
-
328
-    **Figure 2.** Example of the start of the window you should obtain if the program functions correctly.
329
-
330
-    ---
331
-
332
-    ![figure3.png](images/figure3.png)
333
-
334
-    **Figure 3.** Example of the window you should obtain at the end of the program if it is working correctly.
335
-
336
-    ---
337
-
338
-**IMPORTANT:** You SHOULD NOT make any changes in the `main` and `test_BBPlayer` functions, aside from removing the comments.
339
-
340
----
341
-
342
----
343
-
344
-##Deliverables
345
-
346
-Use "Deliverables" in Moodle to hand in the `main.cpp` file. Remember to use good programming techniques, include the name of the programmers involved, and document your program.
347
-
348
----
349
-
350
----
351
-
352
-##References
353
-
354
-[1] http://www.telegraph.co.uk/sport/olympics/basketball/9348826/London-2012-Olympics-Temi-Fagbenle-in-Team-GB-womens-basketball-squad.html
355
-
356
-[2] http://www.musthavemenus.com/category/bar-clipart.html
357
-
358
-[3] http://basketball.isport.com/basketball-guides/finding-your-niche-in-basketball
1
+## [\[English\]](README-en.md) - for README in English
2
+## [\[Spanish\]](README-es.md) - for README in Spanish