Browse Source

Resease version initial commit

Jose Ortiz 9 years ago
commit
52ea4b4921

+ 39
- 0
QuadraticFormula.cpp View File

@@ -0,0 +1,39 @@
1
+#include "frog.h"
2
+
3
+/// \fn frog::QuadraticPlus(int a, int b, int c)
4
+/// \~English
5
+/// \brief Function that returns the result of the negative quadratic formula.
6
+/// \param a: value used to complete the quadratic formula
7
+/// \param b: value used to complete the quadratic formula
8
+/// \param c: value used to complete the quadratic formula
9
+/// \~Spanish
10
+/// \brief Funcion que devuelve el resultado de la formula cuadratica negativa.
11
+/// \param a: valor utilizado para completar la formula quadratica
12
+/// \param b: valor utilizado para completar la formula quadratica
13
+/// \param c: valor utilizado para completar la formula quadratica
14
+double frog::QuadraticPlus(int a, int b, int c){
15
+    double result = 0;
16
+
17
+    // YOUR CODE HERE / TU CODIGO AQUI
18
+
19
+    return result = 0;
20
+}
21
+
22
+/// \fn frog::QuadraticMinus(int a, int b, int c)
23
+/// \~English
24
+/// \brief Function that returns the result of the negative quadratic formula.
25
+/// \param a: value used to complete the quadratic formula
26
+/// \param b: value used to complete the quadratic formula
27
+/// \param c: value used to complete the quadratic formula
28
+/// \~Spanish
29
+/// \brief Funcion que devuelve el resultado de la formula cuadratica negativa.
30
+/// \param a: valor utilizado para completar la formula quadratica
31
+/// \param b: valor utilizado para completar la formula quadratica
32
+/// \param c: valor utilizado para completar la formula quadratica
33
+double frog::QuadraticMinus(int a, int b, int c){
34
+    double result;
35
+
36
+    // YOUR CODE HERE / TU CODIGO AQUI
37
+
38
+    return result;
39
+}

+ 26
- 0
QuadraticFrog.pro View File

@@ -0,0 +1,26 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2014-07-22T10:58:40
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core gui
8
+
9
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+TARGET = QuadraticFrog2
12
+TEMPLATE = app
13
+
14
+
15
+SOURCES += main.cpp\
16
+        mainwindow.cpp \
17
+    frog.cpp \
18
+    QuadraticFormula.cpp
19
+
20
+HEADERS  += mainwindow.h \
21
+    frog.h
22
+
23
+FORMS    += mainwindow.ui
24
+
25
+RESOURCES += \
26
+    resources/images.qrc

+ 271
- 0
QuadraticFrog.pro.user View File

@@ -0,0 +1,271 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE QtCreatorProject>
3
+<!-- Written by QtCreator 3.4.0, 2015-06-20T12:42:14. -->
4
+<qtcreator>
5
+ <data>
6
+  <variable>EnvironmentId</variable>
7
+  <value type="QByteArray">{927fb263-722b-46dd-b3ec-8bedf75b6ed1}</value>
8
+ </data>
9
+ <data>
10
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
11
+  <value type="int">0</value>
12
+ </data>
13
+ <data>
14
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
15
+  <valuemap type="QVariantMap">
16
+   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
17
+   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
18
+   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
19
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
20
+    <value type="QString" key="language">Cpp</value>
21
+    <valuemap type="QVariantMap" key="value">
22
+     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
23
+    </valuemap>
24
+   </valuemap>
25
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
26
+    <value type="QString" key="language">QmlJS</value>
27
+    <valuemap type="QVariantMap" key="value">
28
+     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
29
+    </valuemap>
30
+   </valuemap>
31
+   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
32
+   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
33
+   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
34
+   <value type="int" key="EditorConfiguration.IndentSize">4</value>
35
+   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36
+   <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37
+   <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
38
+   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
39
+   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
40
+   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41
+   <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
42
+   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
43
+   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
44
+   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
45
+   <value type="int" key="EditorConfiguration.TabSize">8</value>
46
+   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
47
+   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
48
+   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
49
+   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
50
+   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
51
+   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
52
+  </valuemap>
53
+ </data>
54
+ <data>
55
+  <variable>ProjectExplorer.Project.PluginSettings</variable>
56
+  <valuemap type="QVariantMap"/>
57
+ </data>
58
+ <data>
59
+  <variable>ProjectExplorer.Project.Target.0</variable>
60
+  <valuemap type="QVariantMap">
61
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.1 clang 64bit</value>
62
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.1 clang 64bit</value>
63
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.clang_64_kit</value>
64
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
65
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
67
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
68
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/joseortiz/Dropbox/proposals/TUES/public/exercises/build-QuadraticFrog-Desktop_Qt_5_4_1_clang_64bit-Debug</value>
69
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
70
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
71
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
72
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
73
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
74
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
75
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
76
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
77
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
78
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
79
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
80
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
81
+     </valuemap>
82
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
83
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
84
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
85
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
86
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
87
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
88
+       <value type="QString">-w</value>
89
+       <value type="QString">-r</value>
90
+      </valuelist>
91
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
92
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
93
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
94
+     </valuemap>
95
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
96
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
97
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
98
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
99
+    </valuemap>
100
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
101
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
102
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
103
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
104
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
105
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
106
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
107
+       <value type="QString">-w</value>
108
+       <value type="QString">-r</value>
109
+      </valuelist>
110
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
111
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
112
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
113
+     </valuemap>
114
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
115
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
116
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
117
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
118
+    </valuemap>
119
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
120
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
121
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
122
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
123
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
124
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
125
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
126
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
127
+   </valuemap>
128
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
129
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/joseortiz/Dropbox/proposals/TUES/public/exercises/build-QuadraticFrog-Desktop_Qt_5_4_1_clang_64bit-Release</value>
130
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
131
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
132
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
134
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
136
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
137
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
138
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
139
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
140
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
141
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
142
+     </valuemap>
143
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
144
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
145
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
146
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
148
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
149
+       <value type="QString">-w</value>
150
+       <value type="QString">-r</value>
151
+      </valuelist>
152
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
153
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
154
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
155
+     </valuemap>
156
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
157
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
158
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
159
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
160
+    </valuemap>
161
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
162
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
163
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
164
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
165
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
167
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
168
+       <value type="QString">-w</value>
169
+       <value type="QString">-r</value>
170
+      </valuelist>
171
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
172
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
173
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
174
+     </valuemap>
175
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
176
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
177
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
178
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
179
+    </valuemap>
180
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
181
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
182
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
183
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
184
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
185
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
186
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
187
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
188
+   </valuemap>
189
+   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
190
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
191
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
192
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
193
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
194
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
195
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
196
+    </valuemap>
197
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
198
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
199
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
200
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
201
+   </valuemap>
202
+   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
203
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
204
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
205
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
206
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
207
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
208
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
209
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
210
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
211
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
212
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
213
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
214
+    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
215
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
216
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
217
+    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
218
+    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
219
+    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
220
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
221
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
222
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
223
+     <value type="int">0</value>
224
+     <value type="int">1</value>
225
+     <value type="int">2</value>
226
+     <value type="int">3</value>
227
+     <value type="int">4</value>
228
+     <value type="int">5</value>
229
+     <value type="int">6</value>
230
+     <value type="int">7</value>
231
+     <value type="int">8</value>
232
+     <value type="int">9</value>
233
+     <value type="int">10</value>
234
+     <value type="int">11</value>
235
+     <value type="int">12</value>
236
+     <value type="int">13</value>
237
+     <value type="int">14</value>
238
+    </valuelist>
239
+    <value type="int" key="PE.EnvironmentAspect.Base">2</value>
240
+    <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
241
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QuadraticFrog</value>
242
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
243
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/joseortiz/Dropbox/proposals/TUES/public/exercises/expressions-quadraticfrog/QuadraticFrog.pro</value>
244
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
245
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QuadraticFrog.pro</value>
246
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
247
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
248
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
249
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
250
+    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
251
+    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
252
+    <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
253
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
254
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
255
+   </valuemap>
256
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
257
+  </valuemap>
258
+ </data>
259
+ <data>
260
+  <variable>ProjectExplorer.Project.TargetCount</variable>
261
+  <value type="int">1</value>
262
+ </data>
263
+ <data>
264
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
265
+  <value type="int">18</value>
266
+ </data>
267
+ <data>
268
+  <variable>Version</variable>
269
+  <value type="int">18</value>
270
+ </data>
271
+</qtcreator>

+ 352
- 0
README.md View File

@@ -0,0 +1,352 @@
1
+[English](#markdown-header-arithmetic-expressions-quadratic-frog) | [Español](#markdown-header-expresiones-aritmeticas-sapo-cuadratico)
2
+
3
+# Expresiones aritméticas - Sapo Cuadrático
4
+
5
+
6
+![main1.png](images/main1.png)
7
+![main2.png](images/main2.png)
8
+![main4.png](images/main4.png)
9
+
10
+
11
+Las expresiones aritméticas son parte esencial de casi cualquier algoritmo que resuelve un problema útil.  Por lo tanto,  implementar expresiones aritméticas correctamente es una destreza básica en cualquier lenguaje de programación de computadoras. En esta experiencia de laboratorio practicarás la implementación de expresiones aritméticas en C++ escribiendo ecuaciones para la fórmula cuadrática y así completar el código para  un juego en el que un sapito brinca de una hoja a otra.
12
+
13
+
14
+##Objetivos:
15
+
16
+1. Implementar expresiones aritméticas en C++ para definir la trayectoria del brinco de un sapito en un juego.
17
+2. Utilizar constantes adecuadamente.
18
+3. Definir variables utilizando tipos de datos adecuados.
19
+4. Convertir el valor de un dato a otro tipo cuando sea necesario.
20
+
21
+
22
+##Pre-Lab:
23
+
24
+Antes de llegar al laboratorio debes:
25
+
26
+1. Haber repasado los siguientes conceptos:
27
+
28
+    a. implementar expresiones aritméticas en C++
29
+
30
+    b. tipos de datos nativos de C++ (int, float, double, char)
31
+
32
+    c. usar "type casting" para covertir el valor de una variable a otro tipo dentro de expresiones.
33
+
34
+    d. utilizar funciones y constantes aritméticas de la biblioteca `cmath`
35
+
36
+    e. ecuaciones cuadráticas y sus gráficas.
37
+
38
+2. haber estudiado los conceptos e instrucciones para la sesión de laboratorio.
39
+
40
+3. haber tomado el quiz Pre-Lab que se encuentra en Moodle.
41
+
42
+---
43
+---
44
+
45
+
46
+
47
+##Fórmula cuadrática
48
+
49
+Una *ecuación cuadrática* tiene la forma 
50
+
51
+$$y = a x^2+ b x + c,$$
52
+
53
+donde $a, b, c$ son números reales y $a\not=0$. La gráfica de una ecuación cuadrática es una *parábola* que abre hacia arriba si $a > 0$ y abre hacia abajo si $a < 0$. 
54
+
55
+Una gráfica interseca el eje de $x$ cuando $y=0$. Por lo tanto, si una parábola interseca el eje de $x$, los intersectos están dados por las soluciones reales de la ecuación
56
+
57
+$$0 = a x^2 + b x + c.$$
58
+
59
+Las soluciones a la ecuación anterior se pueden obtener utilizando la *fórmula cuadrática*:
60
+
61
+$$x=\frac{-b±\sqrt{b^2-4ac}}{2a}.$$
62
+
63
+Nota que si el *discriminante*  $b^2-4ac$ de la fórmula cuadrática es negativo, los valores de $x$ serán números imaginarios y no se pueden graficar en el plano cartesiano porque los puntos $(x,y)$ en este plano tienen coordenadas que son números reales. Por lo tanto, si el discriminante es negativo, la parábola no interseca el eje de $x$. Si el discriminate es igual a $0$, entonces la parábola interseca el eje de $x$ en un solo punto (solo el vértice toca el eje de $x$).
64
+
65
+Si el discriminante es positivo, la fórmula cuadrática nos dá dos soluciones a la ecuación $0 = a x^2 + b x + c$ y estas soluciones son los intersectos en el eje de $x$. Por ejemplo, supón que la fórmula cuadrática nos dá dos valores 
66
+
67
+$$x=x_1$$
68
+$$x=x_2$$
69
+
70
+Entonces, 
71
+
72
+$$a x^2 + b x + c = a(x-x_1)(x-x_2),$$
73
+
74
+
75
+donde $x_1$ y $x_2$ son los cortes en el eje de $x$. Si $a<0$, la gráfica de la parábola será similar a la de la Figura 1.
76
+
77
+---
78
+
79
+![parabola.png](images/parabola.png)
80
+
81
+<b>Figura 1.</b> Parábola que abre hacia abajo e interseca el eje de $x$ en $x_1$ y $x_2$.
82
+
83
+
84
+---
85
+
86
+Nota que la ecuación
87
+
88
+$$y=-(x-x_1)(x-x_2)$$
89
+
90
+es una ecuación cuadrática cuya parábola abre hacia abajo e  interseca el eje de $x$ en  $x_1$ y $x_2$. Por ejemplo, la ecuación
91
+
92
+$$y=-(x+2)(x-3)=-x^2+x+6$$
93
+
94
+es una ecuación cuadrática cuya parábola abre hacia abajo e interseca el eje de $x$ en $x_1=-2$ y $x_2=3$. Nota que, en esta ecuación, los valores de $a,b,c$  son $a=-1, \ b=1, \ c=6$.
95
+
96
+---
97
+---
98
+
99
+##Sesión de laboratorio:
100
+
101
+###Ejercicio 1
102
+
103
+En este ejercicio implementarás la fórmula cuadrática para completar un juego en el que un sapito brinca de una hoja a otra. Asumirás que las hojas están localizadas sobre el eje de $x$ y que el brinco del sapito estará determinado por una parábola que abre hacia abajo. Si quieres que el sapito brinque de hoja a hoja, debes hayar una ecuación cuadrática cuya parábola abra hacia abajo e interseque el eje de $x$ en los lugares donde están localizadas las hojas. Tu tarea es escribir las ecuaciones para la fórmula cuadrática.
104
+
105
+
106
+
107
+**Instrucciones**
108
+
109
+1.   Carga a Qt el proyecto `QuadraticFrog`  haciendo doble "click" en el archivo `QuadraticFrog.pro` que se encuentra en la carpeta `Documents/eip/Expressions-QuadraticFrog` de tu computadora. También puedes ir a `http://bitbucket.org/eip-uprrp/quadraticfrog` para descargar la carpeta `QuadraticFrog` a tu computadora.
110
+
111
+2. Configura el proyecto y ejecuta el programa marcando la flecha verde en el menú de la izquierda de la ventana de Qt Creator. El programa te dará un mensaje que dice que la fórmula cuadrática está mal escrita. Esto sucede porque el programa tiene instrucciones que prueban el programa y verifican que la implementación del código esté correcta. Tu programa aún no tiene las instrucciones para evaluar la fórmula cuadrática y por esto sale el mensaje. 
112
+
113
+3. En el archivo `QuadraticFormula.cpp` (en `Sources`) escribirás las ecuaciones para la fórmula cuadrática. En la función `QuadraticPlus` añade la ecuación
114
+
115
+    $$result=\frac{-b+\sqrt{b^2-4ac}}{2a},$$
116
+
117
+    y en la función `QuadraticMinus` añade la ecuación
118
+
119
+    $$result=\frac{-b-\sqrt{b^2-4ac}}{2a}.$$
120
+
121
+    Los otros archivos del proyecto tienen código que hará pruebas a  las ecuaciones que escribiste evaluando varios valores para $a, b ,c$ y verificando que el resultado que producen las ecuaciones es el esperado.  La validación del código de un programa es una parte importante de el desarrollo de programas y proyectos.
122
+
123
+4. Ejecuta el programa marcando el botón verde en el menú de la izquierda. Si las ecuaciones que escribiste están correctas, deberá aparecer una ventana parecida a la Figura 2.
124
+
125
+    ---
126
+
127
+    ![figure2.png](images/figure2.png)
128
+
129
+    <b>Figura 2.</b> Ventana del juego *Quadratic Frog*.
130
+
131
+
132
+    ---
133
+
134
+
135
+5. Entrega el archivo `QuadraticFormula.cpp` que contiene las funciones las funciones `QuadraticPlus` y `QuadraticMinus` utilizando   "Entrega 1" en Moodle. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
136
+
137
+6. Para jugar, el sapito deberá brincar de una hoja a otra. Nota que las hojas tienen valores para $x_1$ y $x_2$. Estos valores representan los intercectos en el eje de $x$ de la parábola. Debes entrar los valores para los coeficientes $a,b,c$ de la ecuación cuadrática de modo que la gráfica sea una parábola que abra hacia abajo e interseque el eje de $x$ en los valores $x_1, x_2$ que salen en las hojas. Puedes obtener los valores de $a,b,c$ notando que 
138
+
139
+ $$a x^2 + b x + c = a(x-x_1)(x-x_2),$$
140
+
141
+ como en la explicación de arriba. 
142
+
143
+
144
+
145
+###Ejercicio 2
146
+
147
+En este ejercicio escribirás un  programa para obtener el promedio de puntos para la nota de un estudiante.
148
+
149
+Supón que todos los cursos en la Universidad de Yauco son de $3$ créditos y que las notas tienen las siguientes puntuaciones: $A = 4$ puntos por crédito; $B = 3$ puntos por crédito; $C = 2$ puntos por crédito; $D = 1$ punto por crédito y $F = 0$ puntos por crédito. 
150
+
151
+**Instrucciones**
152
+
153
+1. Crea un nuevo proyecto "Non-Qt" llamado Promedio. Tu función `main()`  contendrá el código necesario para pedirle al usuario el número de A's, B's, C's, D's y F's obtenidas por el estudiante y computar el promedio de puntos para la nota (GPA por sus siglas en inglés).
154
+
155
+2. Tu código debe definir las constantes $A=4, B=3, C=2, D=1, F=0$ para la puntuación de las notas, y pedirle al usuario que entre los valores para las variables $NumA$, $NumB$, $NumC$, $NumD$, $NumF$. La variable $NumA$ representará el número de cursos en los que el estudiante obtuvo $A$,  $NumB$ representará el número de cursos en los que el estudiante obtuvo $B$, etc. El programa debe desplegar el GPA del estudiante en una escala de 0 a 4 puntos. 
156
+
157
+
158
+
159
+    **Ayudas:** 
160
+
161
+    1. El promedio se obtiene sumando las puntuaciones  correspondientes a las notas obtenidas (por ejemplo, una A en un curso de 3 créditos tiene una puntuación de 12), y dividiendo esa suma por el número total de créditos.
162
+
163
+    2. Recuerda que, en C++, si divides dos números enteros el resultado se "truncará" y será un número entero. Utiliza "type casting": `static_cast\<tipo\>(expresión)' para resolver este problema.
164
+
165
+3. Verifica tu programa calculando el promedio de un estudiante que tenga dos A y dos B; ¿qué nota tendría este estudiante, A o B (la A va desde 3.5 a 4.0)?. Cuando tu programa esté correcto, guarda el archivo `main.cpp` y entrégalo  utilizando  "Entrega 2" en Moodle. Recuerda seguir las instrucciones en el uso de nombres y tipos para las variables,  incluir el nombre de los programadores, documentar tu programa y utilizar buenas prácticas de programación. 
166
+
167
+
168
+---
169
+---
170
+---
171
+
172
+
173
+
174
+[English](#markdown-header-arithmetic-expressions-quadratic-frog) | [Español](#markdown-header-expresiones-aritmeticas-sapo-cuadratico)
175
+
176
+# Arithmetic Expressions - Quadratic Frog
177
+
178
+![main1.png](images/main1.png)
179
+![main2.png](images/main2.png)
180
+![main4.png](images/main4.png)
181
+
182
+
183
+Arithmetic expressions are an essential part of almost any algorithm that solves a useful problem. Therefore, a basic skill in any computer programming language is to implement arithmetic expressions correctly. In this laboratory experience you will practice the implementation of arithmetic expressions in C++ by writing equations for the quadratic formula and complete the code for a game in which a frog jumps from leaf to leaf.
184
+
185
+##Objectives:
186
+
187
+1. To implement arithmetic expressions in C++ to produce graphs. 
188
+2. To use constants adequately. 
189
+3. To define variables using adequate data types.
190
+4. To cast a data value to another type when necessary.
191
+
192
+
193
+##Pre-Lab:
194
+
195
+Before you get to the laboratory you should have:
196
+
197
+1. Reviewed the following concepts:
198
+
199
+    a. implementing arithmetic expressions in C++.
200
+
201
+    b. native data types in C++ (int, float, double)
202
+
203
+    c. using  "type casting" to cast the value of variables to other data types within expressions.
204
+
205
+    d. using arithmetic functions and constants from the `cmath` library.
206
+
207
+    e. quadratic equations and their graphs.
208
+
209
+2. Studied the concepts and instructions for the laboratory session.
210
+
211
+3. Taken the Pre-Lab quiz that can be found in Moodle.
212
+
213
+
214
+
215
+---
216
+---
217
+
218
+
219
+
220
+##Quadratic Formula
221
+
222
+A *quadratic equation* has a form 
223
+
224
+
225
+$$y = a x^2+ b x + c,$$
226
+
227
+where $a, b, c$ are real numbers and $a\not=0$. The graph of a quadratic equation is a *parabola* that opens up if $a > 0$ and opens dawn if $a < 0$.
228
+
229
+A graph intersects the $x$-axis when $y=0$. Therefore, if a parabola intersects the $x$-axis, the intersects are given by the real solutions to the equation
230
+
231
+
232
+
233
+$$0 = a x^2 + b x + c.$$
234
+
235
+The solutions to the previous equation can be obtained using the *quadratic formula*:
236
+
237
+
238
+
239
+$$x=\frac{-b±\sqrt{b^2-4ac}}{2a}.$$
240
+
241
+Note that if the *discriminant*   $b^2-4ac$ of the quadratic formula is negative, the values of $x$ are complex numbers and are not plotted in the Cartesian plane. Therefore, if the discriminant is negative, the parabola does not intersect the $x$-axis. If the discriminant is equal to $0$, then the parabola intersects the $x$-axis in only one point (only the vertex touches the $x$-axis).
242
+
243
+If the discriminant is positive, the quadratic formula gives two solutions to the equation $0 = a x^2 + b x + c$ and these solutions are the intersects in the $x$-axis. For example, suppose that the quadratic formula gives two values
244
+
245
+
246
+
247
+$$x=x_1$$
248
+$$x=x_2$$
249
+
250
+Then, 
251
+
252
+$$a x^2 + b x + c = a(x-x_1)(x-x_2),$$
253
+
254
+where $x_1$ and $x_2$ are the intersects in the $x$-axis. If $a<0$, the graph of the parabola will be similar to the one in Figure 1.
255
+
256
+---
257
+
258
+![parabola.png](images/parabola.png)
259
+
260
+<b>Figure 1.</b> Parabola that opens down and intersects the $x$-axis in $x_1$ and $x_2$.
261
+
262
+
263
+---
264
+
265
+Note that the equation
266
+
267
+
268
+$$y=-(x-x_1)(x-x_2)$$
269
+
270
+is a quadratic equation and its parabola opens down and intersects the $x$-axis in $x_1$ and $x_2$. For example, the equation
271
+
272
+
273
+$$y=-(x+2)(x-3)=-x^2+x+6$$
274
+
275
+is a quadratic equation with a parabola that opens down and intersects the $x$-axis at $x_1=-2$ and $x_2=3$. Note that, in this equation, the values for $a, b, c$ are  $a=-1, \ b=1, \ c=6$.
276
+
277
+
278
+---
279
+---
280
+
281
+##Laboratory session:
282
+
283
+###Exercise 1
284
+
285
+In this exercise you will implement the quadratic formula to complete a game in which a frog leaps from one leaf to another. You will assume that the leaves are in the $x$-axis and that the leap is determined by a parabola that opens down. If you want the frog to leap from leaf to leaf, you must find a quadratic equation with a parabola that opens down and intersects the $x$-axis in the places where the leaves are located. Your task is to write the equations for the quadratic formula.
286
+
287
+
288
+
289
+**Instructions**
290
+
291
+1.   Double click the file `QuadraticFrog.pro` that is contained in the `Documents/eip/Expressions-QuadraticFrog` folder to load the project `QuadraticFrog` into Qt. You can also download the folder `Expressions-QuadraticFrog` from  `http://bitbucket.org/eip-uprrp/expressions-quadraticfrog`.
292
+
293
+
294
+2. Configure the project and run the program by clicking the green arrow in the menu on the left side of the Qt Creator window. The program will display a message saying that the quadratic formula is wrong. This happens because the program has testing instructions that verify that the code implementation is correct. Your program is missing the code for the quadratic formula and this is why the message is displayed.
295
+
296
+3. You will write the equations for the quadratic formula in the file In the file  `QuadraticFormula.cpp` (in `Sources`). In the function  `QuadraticPlus` add the equation
297
+
298
+    $$result=\frac{-b+\sqrt{b^2-4ac}}{2a},$$
299
+
300
+    and in the function `QuadraticMinus` add the equation
301
+
302
+    $$result=\frac{-b-\sqrt{b^2-4ac}}{2a}.$$
303
+
304
+    The other files of the project have code that will test your equations by evaluating several choices for $a, b, c$ and verifying that the equations produce the expected result. Code validation is an important part of software development.
305
+
306
+
307
+4. Run the program by clicking the green arrow in the menu on the left side of the Qt Creator window. If your equations are implemented correclty, you should obtain a window similar to the one in Figure 2.
308
+
309
+    ---
310
+
311
+    ![figure2.png](images/figure2.png)
312
+
313
+    <b>Figure 2.</b> Window of the game *Quadratic Frog*.
314
+
315
+
316
+    ---
317
+
318
+
319
+5. Use "Deliverable 1" in Moodle to submit the file  `QuadraticFormula.cpp` containing the code with the functions `QuadraticPlus` and `QuadraticMinus`. Remember to use good programming practices, to include the names of the programmers and to document your program.
320
+
321
+6. To play, the frog should leap jump from one leaf to another. Note that the leaves have values for $x_1$ and $x_2$. These values represent the intersects of the parabola with the $x$-axis. You should input the values for the coefficients $a, b, c$ of the quadratic equation so that its graph that is a parabola that opens down and intersects the $x$-axis in the values $x_1, x_2$ shown in the leaves. You can obtain these values noting that
322
+
323
+
324
+ $$a x^2 + b x + c = a(x-x_1)(x-x_2),$$
325
+
326
+ as in the explanation above. 
327
+
328
+
329
+
330
+
331
+###Exercise 2
332
+
333
+In this exercise you will write a program to obtain a student's grade point average (GPA).
334
+
335
+Suppose that all courses in Cheo's University are 3 credits each and have the following point values: $A = 4$ points per credit; $B = 3$ points per credit; $C = 2$ points per credit; $D = 1$ point per credit y $F = 0$ points per credit. 
336
+
337
+**Instructions**
338
+
339
+1. Start a new "Non-Qt" project called "Average". Your `main()` function will contain the necessary code to ask the user for the number of A's, B's, C's, D's and F's obtained and compute the grade point average (GPA).
340
+
341
+2. Your code should define the constants  $A=4, B=3, C=2, D=1, F=0$ for the points per credit, and ask the user to input the values for the variables  $NumA$, $NumB$, $NumC$, $NumD$, $NumF$. The variable $NumA$ represents the number of courses in which the student obtained A, $NumB$ represents the number of courses in which the student obtained B, etc. The program should display the GPA using the 0-4 point scale.
342
+
343
+    **Hints:** 
344
+
345
+    1. You can obtain the GPA by adding the credit points corresponding to the grades (for example, an A in a 3 credit course has a value of 12 points), and dividing this sum by the total number of credits.
346
+
347
+
348
+    2. Remember that, in C++, when both operands in the division are integers, the result will also be an integer; the remainder will be discarded. Use "type casting": `static_cast\<type\>(expression)' to solve this problem.
349
+
350
+3. Verify your program by computing the GPA of a student that has two A's and 2 B's; what is the grade of this student, A or B (A goes from 3.5 to 4 points)? When your program is correct, save the `main.cpp` file and submit it using "Deliverable 2" in Moodle. Remember to follow the instructions regarding the names and types of the variables,  to include the names of the programmers, to document your program and to use good programming practices.
351
+
352
+

+ 296
- 0
frog.cpp View File

@@ -0,0 +1,296 @@
1
+///
2
+/// Modifications:
3
+///     - 2015-06-05 [Ian Davila] - Changed Frogger's location
4
+///
5
+#include "frog.h"
6
+#include <QDebug>
7
+#include <cstdlib>
8
+#include <ctime>
9
+#include <cassert>
10
+#include <QMessageBox>
11
+#include "mainwindow.h"
12
+#include "ui_mainwindow.h"
13
+
14
+/// \fn frog::frog(QWidget *parent)
15
+/// \~English
16
+/// \brief Default constructor.
17
+/// * Ysapo: Y coordinate of the frog, set at 190 so it sits on top of the leaf
18
+/// * Xsapo: X coordinate of the frog, a random number from 0 to -30
19
+/// * xnenu, xnenu2, xnenu3: X coordinates of the leafs
20
+/// * textBool: Boolean for the labels on the leafs
21
+/// * temp, temp2: X coordinate of the background
22
+/// \~Spanish
23
+/// \ brief Constructor por defecto.
24
+/// * Ysapo: Coordenada Y del sapo, inicializado a 190 para que aparesca encima del nenufar
25
+/// * Xsapo: Coordenada X del sapo, un numero aleatorio de 0 a -30
26
+/// * xnenu, xnenu2, xnenu3: coordenadas x de las hojas
27
+/// * textBool: Booleana para las etiquetas de los nenufares
28
+/// * temp, temp2: Coordenada X del fondo
29
+///
30
+frog::frog(QWidget *parent) :
31
+    QWidget(parent)
32
+{
33
+    myTimer= new QTimer(this);
34
+    flag = xFlag = backFlag = moved = textBool = false;
35
+    Ysapo = 190;
36
+    A = B = C = 0;
37
+    temp = 580;
38
+    temp2 = 0;
39
+    xnenu = -(rand()%30);
40
+    initialX = Xsapo = xnenu;
41
+    xnenu2 = (rand() % 100) + 100;
42
+    xnenu3 = xnenu2 + (rand() % 100) + 200;
43
+}
44
+
45
+/// \fn void frog::updatenenu()
46
+/// \~English
47
+/// \brief Function that updates the position of the frog and the leafs
48
+///  when the frog reaches the end of the screen when it's sliding back.
49
+/// \~Spanish
50
+/// \brief Funcion que actualiza la posicion del sapo y los nenufares
51
+///  cuando el sapo llega al final de la pantalla cuando se desliza hacia atras.
52
+///
53
+void frog::updatenenu(){
54
+    xnenu = -(rand() % 30);
55
+    initialX = Xsapo = xnenu;
56
+    xnenu2 = (rand() % 100) + 100;
57
+    xnenu3 = xnenu2 + (rand() % 100) + 200;
58
+}
59
+
60
+/// \fn void frog::reset()
61
+/// \~English
62
+/// \brief Function that is invoked when the retry button is clicked, resets
63
+///  the frog and the leafs to a random starting position.
64
+/// \~Spanish
65
+/// \brief Funcion que es invocada cuando el boton de "retry" es presionado,
66
+///  restablece el sapo y los nenufares a una posicion de partida aleatoria.
67
+///
68
+void frog::reset(){
69
+    flag = xFlag = backFlag = moved = textBool = false;
70
+    Ysapo = 190;
71
+    A = B = C = 0;
72
+    temp = 580;
73
+    temp2 = 0;
74
+    repaint();
75
+    myTimer->stop();
76
+    delete myTimer;
77
+    myTimer = new QTimer;
78
+    connect(myTimer, SIGNAL(timeout()), this, SLOT(mySlot()));
79
+    xnenu = -(rand() %30);
80
+    initialX = Xsapo = xnenu;
81
+    xnenu2 = (rand() % 100) + 100;
82
+    xnenu3 = xnenu2 + (rand() % 100) + 200;
83
+
84
+}
85
+
86
+/// \fn void frog::paintEvent(QPaintEvent *event)
87
+/// \~English
88
+/// \brief Function that is invoked each time the widget or
89
+///  its parent receives a repaint signal.
90
+/// \~Spanish
91
+/// \brief Funcion que es invocada automaticamente cada vez que el widget
92
+///  o su padre recive una senal de repintar.
93
+///
94
+void frog::paintEvent(QPaintEvent *){
95
+    QPainter p(this);
96
+    QString frogger = ":/images/Frogger1.png";
97
+    QString frogger2 = ":/images/Frogger2.png";
98
+    QString frogger3 = ":/images/Frogger3.png";
99
+    QString leaf = ":/images/Nenufar1.png";
100
+    QString back = ":/images/background.jpg";
101
+
102
+    //Conditions that allow a margin of error (not landing in the exact x calculated)
103
+    if(backFlag == true || (Xsapo <= (xnenu3 + 55) && Xsapo >= (xnenu3 - 55) && Ysapo == 190)
104
+            || (Xsapo > xnenu && Ysapo == 190 && Xsapo < (xnenu2-55))
105
+            || (Xsapo > xnenu2 && Ysapo == 190 && Xsapo < (xnenu3-55))
106
+            || (Xsapo > xnenu3 && Ysapo == 190)){
107
+
108
+        backFlag = true;
109
+        myTimer->stop();
110
+        delete myTimer;
111
+        myTimer = new QTimer;
112
+        QThread::msleep(5);
113
+        connect(myTimer, SIGNAL(timeout()), this, SLOT(mySlot()));
114
+
115
+        // Draw background
116
+        p.drawPixmap(temp2,-5,600,400,QPixmap(back));
117
+        p.drawPixmap(temp,-5,600,400,QPixmap(back));
118
+
119
+        // Draw leaves
120
+        p.drawPixmap(xnenu,230,125,60,QPixmap(leaf));
121
+        p.drawPixmap(xnenu2,230,125,60,QPixmap(leaf));
122
+        p.drawPixmap(xnenu3,230,125,60,QPixmap(leaf));
123
+
124
+        // Draw text labels
125
+        p.drawText(xnenu2+45,310,"x1 = " + QString::number(xnenu2));
126
+        p.drawText(xnenu3+45,310,"x2 = " + QString::number(xnenu3));
127
+
128
+        // Moves everything on the screen back on the x-axis
129
+        Xsapo=Xsapo-1;
130
+        xnenu=xnenu-1;
131
+        xnenu2=xnenu2-1;
132
+        xnenu3=xnenu3-1;
133
+        temp= temp - 1;
134
+        temp2 = temp2 -1;
135
+
136
+        repaint();
137
+
138
+        // When the frog reaches the end of the screen reset everything to a start position
139
+        if(temp == 0 || xnenu3 == -10 || Xsapo == 0){
140
+            backFlag = false;
141
+            temp = 580;
142
+            temp2 = 0;
143
+            moved = true;
144
+            textBool = false;
145
+            updatenenu();
146
+        }
147
+
148
+    }else{
149
+          QFont font = p.font();
150
+          font.setBold(true);
151
+          p.setFont(font);
152
+
153
+          // Draw background
154
+          p.drawPixmap(temp2,-5,600,400,QPixmap(back));
155
+          p.drawPixmap(temp,-5,600,400,QPixmap(back));
156
+
157
+          // Draw leaves
158
+          p.drawPixmap(xnenu,230,125,60,QPixmap(leaf));
159
+          p.drawPixmap(xnenu2,230,125,60,QPixmap(leaf));
160
+          p.drawPixmap(xnenu3,230,125,60,QPixmap(leaf));
161
+
162
+          //Cambiada la condicion para que sea exacta la caida en el nenufar // Funciona con esta condición
163
+          if(Xsapo < (xnenu2 + 55) && Ysapo == 190 && Xsapo > (xnenu2-55)){
164
+               textBool = true;
165
+          }
166
+
167
+          // When the frog lands on the second leaf, change labels to next leaf
168
+          if(Ysapo == 190 && Xsapo == xnenu2){
169
+            textBool = true;
170
+          }
171
+
172
+          if(textBool){
173
+              // Redraw the text labels
174
+              p.drawText(xnenu2+35,310,"x1 = " + QString::number(xnenu2)); // de 290 a 310
175
+              p.drawText(xnenu3+35,310,"x2 = " + QString::number(xnenu3));
176
+              p.drawPixmap(xnenu,230,125,60,QPixmap(leaf)); // 250 a 230
177
+          }else{
178
+              p.drawText(xnenu2+35,310,"x2 = " + QString::number(xnenu2)); // de 290 a 310
179
+          }
180
+    }
181
+
182
+    //Cambiada la condicion para que sea exacta la caida en el nenufar
183
+    if((Xsapo > (xnenu + 55) && Ysapo == 190 && Xsapo < (xnenu2-55))
184
+        || (Xsapo > (xnenu2 + 55) && Ysapo == 190 && Xsapo < (xnenu3-55))
185
+        || (Xsapo > (xnenu3 + 55) && Ysapo == 190)){
186
+
187
+        p.drawPixmap(Xsapo, Ysapo + 30, 100, 80, QPixmap(frogger3));
188
+
189
+    }else if(Ysapo < 190){
190
+       p.drawPixmap(Xsapo,Ysapo,100,100,QPixmap(frogger2));
191
+
192
+    }else if(Ysapo == 190){
193
+        qDebug() << "xsapo: " << Xsapo << "xnenu2: " << xnenu2;
194
+        p.drawPixmap(Xsapo + 15,Ysapo - 20 ,100,100,QPixmap(frogger)); //+15 a la Xsapo, -20 a Ysapo
195
+        if(!textBool){
196
+            p.drawText(xnenu+45,310,"x1 = " + QString::number(xnenu+10));
197
+        }
198
+    }
199
+}
200
+
201
+/// \fun frog::~frog()
202
+/// \~English
203
+/// \brief Default destructor.
204
+/// \~Spanish
205
+/// \brief Destructor por defecto.
206
+///
207
+frog::~frog(){
208
+    delete myTimer;
209
+}
210
+
211
+/// \fun void frog::mySlot()
212
+/// \~English
213
+/// \brief Function connected to a timer, used to simulate the
214
+///  frog's jump.
215
+/// \~Spanish
216
+/// \brief Funcion conectada a un reloj, utilizada para simular
217
+///  el brinco del sapo
218
+///
219
+void frog::mySlot(){
220
+    float interX1 = 0;
221
+    float interX2 = 0;
222
+    float temp = 0;
223
+    float y = 0;
224
+    float xtemp = 0;
225
+    float xEnd = 0;
226
+
227
+    interX1 = QuadraticMinus(A,B,C);
228
+    interX2 = QuadraticPlus(A,B,C);
229
+
230
+    if(interX1 > interX2){
231
+        temp = interX1;
232
+        interX1 = interX2;
233
+        interX2 = temp;
234
+    }
235
+    if(moved){
236
+        moved = false;
237
+        initialX = Xsapo;
238
+    }
239
+
240
+    xEnd = interX2 + initialX;
241
+        y = 1;
242
+        xtemp = 1;
243
+        if(!xFlag){
244
+            Ysapo = Ysapo - y;
245
+            Xsapo = Xsapo + xtemp;
246
+        }
247
+        else if(xFlag){
248
+            Ysapo = Ysapo + y;
249
+            Xsapo = Xsapo + xtemp;
250
+        }
251
+
252
+        if(int(Xsapo) == int(xEnd/2)){
253
+            xFlag = true;
254
+        }
255
+
256
+    repaint();
257
+    if((int(Xsapo) == int(xEnd) && xFlag == true) || Ysapo == 190){
258
+        Ysapo = 190;
259
+        repaint();
260
+
261
+        myTimer->stop();
262
+        delete myTimer;
263
+        myTimer = new QTimer;
264
+        connect(myTimer, SIGNAL(timeout()), this, SLOT(mySlot()));
265
+
266
+        initialX = Xsapo;
267
+        xFlag = false;
268
+    }
269
+
270
+}
271
+
272
+/// \fn void frog::run(int aa, int bb, int cc)
273
+/// \~English
274
+/// \brief Function that is invoked when the jump button is
275
+///  pressed, makes the frog jump to the coordinates calculated
276
+///  with the a, b, c values provided by the user.
277
+/// \param aa value provided by user to complete the quadratic equation ax^2 + bx + c
278
+/// \param bb value provided by user to complete the quadratic equation ax^2 + bx + c
279
+/// \param cc value provided by user to complete the quadratic equation ax^2 + bx + c
280
+/// \~Spanish
281
+/// \brief Funcion que es invocada cuando el boton de brincar es
282
+///  presionado, hace que el sapo salte a las coordenadas calculadas
283
+///  con los valores de a, b, c proporcionados por el usuario.
284
+/// \param aa valor proporcionado por el usuario utilizado para completar la ecuacion cuadratica ax^2 + bx + c
285
+/// \param bb valor proporcionado por el usuario utilizado para completar la ecuacion cuadratica ax^2 + bx + c
286
+/// \param cc valor proporcionado por el usuario utilizado para completar la ecuacion cuadratica ax^2 + bx + c
287
+///
288
+void frog::run(int aa, int bb, int cc){
289
+
290
+    A = aa;
291
+    B = bb;
292
+    C = cc;
293
+
294
+    connect(myTimer, SIGNAL(timeout()), this, SLOT(mySlot()));
295
+    myTimer->start(25);
296
+}

+ 150
- 0
frog.h View File

@@ -0,0 +1,150 @@
1
+#ifndef FROG_H
2
+#define FROG_H
3
+
4
+#include <QWidget>
5
+#include <QPainter>
6
+#include <QtGui>
7
+#include <QtCore>
8
+#include <QTimer>
9
+#include <QLabel>
10
+
11
+
12
+/// Class that represent the frog and leaves.
13
+///
14
+/// Frog is a subclass of QWidget.
15
+
16
+class frog : public QWidget
17
+{
18
+    Q_OBJECT
19
+public:
20
+
21
+    /// \fn frog::frog(QWidget *parent)
22
+    /// \~English
23
+    /// \brief Default constructor.
24
+    /// * Ysapo: Y coordinate of the frog, set at 190 so it sits on top of the leaf
25
+    /// * Xsapo: X coordinate of the frog, a random number from 0 to -30
26
+    /// * xnenu, xnenu2, xnenu3: X coordinates of the leafs
27
+    /// * textBool: Boolean for the labels on the leafs
28
+    /// * temp, temp2: X coordinate of the background
29
+    /// \~Spanish
30
+    /// \ brief Constructor por defecto.
31
+    /// * Ysapo: Coordenada Y del sapo, inicializado a 190 para que aparesca encima del nenufar
32
+    /// * Xsapo: Coordenada X del sapo, un numero aleatorio de 0 a -30
33
+    /// * xnenu, xnenu2, xnenu3: coordenadas x de las hojas
34
+    /// * textBool: Booleana para las etiquetas de los nenufares
35
+    /// * temp, temp2: Coordenada X del fondo
36
+    ///
37
+    explicit frog(QWidget *parent = 0);
38
+
39
+    /// \fn frog::QuadraticPlus(int a, int b, int c)
40
+    /// \~English
41
+    /// \brief Function that returns the result of the positive quadratic formula.
42
+    /// \param a: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
43
+    /// \param b: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
44
+    /// \param c: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
45
+    /// \~Spanish
46
+    /// \brief Funcion que devuelve el resultado de la formula cuadratica positiva.
47
+    /// \param a: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
48
+    /// \param b: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
49
+    /// \param c: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
50
+    ///
51
+    double QuadraticPlus(int a, int b, int c);
52
+
53
+    /// \fn frog::QuadraticMinus(int a, int b, int c)
54
+    /// \~English
55
+    /// \brief Function that returns the result of the negative quadratic formula.
56
+    /// \param a: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
57
+    /// \param b: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
58
+    /// \param c: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
59
+    /// \~Spanish
60
+    /// \brief Funcion que devuelve el resultado de la formula cuadratica negativa.
61
+    /// \param a: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
62
+    /// \param b: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
63
+    /// \param c: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
64
+    ///
65
+    double QuadraticMinus(int a, int b, int c);
66
+
67
+    /// \fun frog::~frog()
68
+    /// \~English
69
+    /// \brief Default destructor.
70
+    /// \~Spanish
71
+    /// \brief Destructor por defecto.
72
+    ///
73
+    ~frog();
74
+
75
+
76
+    float Ysapo; /**< Y coordinate of the frog*/
77
+    float Xsapo; /**< X coordinate of the frog*/
78
+    float initialX; /**< Initial position of the frog*/
79
+    bool flag, xFlag, backFlag, moved, textBool;
80
+    int A, B, C, buttonCounter,temp,temp2,xnenu,xnenu2,xnenu3;
81
+
82
+
83
+signals:
84
+
85
+public slots:
86
+    /// \fun void frog::mySlot()
87
+    /// \~English
88
+    /// \brief Function connected to a timer, used to simulate the
89
+    ///  frog's jump.
90
+    /// \~Spanish
91
+    /// \brief Funcion conectada a un reloj, utilizada para simular
92
+    ///  el brinco del sapo
93
+    ///
94
+    void mySlot();
95
+
96
+    /// \fn void frog::run(int , int , int )
97
+    /// \~English
98
+    /// \brief Function that is invoked when the jump button is
99
+    ///  pressed, makes the frog jump to the coordinates calculated
100
+    ///  with the a, b, c values provided by the user.
101
+    /// \param aa value provided by user to complete the quadratic equation ax^2 + bx + c
102
+    /// \param bb value provided by user to complete the quadratic equation ax^2 + bx + c
103
+    /// \param cc value provided by user to complete the quadratic equation ax^2 + bx + c
104
+    /// \~Spanish
105
+    /// \brief Funcion que es invocada cuando el boton de brincar es
106
+    ///  presionado, hace que el sapo salte a las coordenadas calculadas
107
+    ///  con los valores de a, b, c proporcionados por el usuario.
108
+    /// \param aa valor proporcionado por el usuario utilizado para completar la ecuacion
109
+    ///  cuadratica ax^2 + bx + c
110
+    /// \param bb valor proporcionado por el usuario utilizado para completar la ecuacion
111
+    ///  cuadratica ax^2 + bx + c
112
+    /// \param cc valor proporcionado por el usuario utilizado para completar la ecuacion
113
+    /// cuadratica ax^2 + bx + c
114
+    void run(int, int, int);
115
+
116
+    /// \fn void frog::reset()
117
+    /// \~English
118
+    /// \brief Function that is invoked when the retry button is clicked, resets
119
+    ///  the frog and the leafs to a random starting position.
120
+    /// \~Spanish
121
+    /// \brief Funcion que es invocada cuando el boton de "retry" es presionado,
122
+    ///  restablece el sapo y los nenufares a una posicion de partida aleatoria.
123
+    ///
124
+    void reset();
125
+
126
+    /// \fn void frog::updatenenu()
127
+    /// \~English
128
+    /// \brief Function that updates the position of the frog and the leafs
129
+    ///  when the frog reaches the end of the screen when it's sliding back.
130
+    /// \~Spanish
131
+    /// \brief Funcion que actualiza la posicion del sapo y los nenufares
132
+    ///  cuando el sapo llega al final de la pantalla cuando se desliza hacia atras.
133
+    ///
134
+    void updatenenu();
135
+
136
+protected:
137
+    /// \fn void frog::paintEvent(QPaintEvent *event)
138
+    /// \~English
139
+    /// \brief Function that is invoked each time the widget or
140
+    ///  its parent receives a repaint signal.
141
+    /// \~Spanish
142
+    /// \brief Funcion que es invocada automaticamente cada vez que el widget
143
+    ///  o su padre recive una senal de repintar.
144
+    ///
145
+    void paintEvent(QPaintEvent *event);
146
+    QTimer *myTimer;
147
+
148
+};
149
+
150
+#endif // FROG_H

BIN
images/figura1.png View File


BIN
images/figure1.jpg View File


BIN
images/figure2.png View File


BIN
images/main1.png View File


BIN
images/main2.png View File


BIN
images/main3.png View File


BIN
images/main4.png View File


BIN
images/parabola.png View File


+ 15
- 0
main.cpp View File

@@ -0,0 +1,15 @@
1
+#include <QApplication>
2
+#include "mainwindow.h"
3
+#include <cstdlib>
4
+#include <ctime>
5
+
6
+int main(int argc, char *argv[])
7
+{
8
+    srand(time(NULL));
9
+    QApplication a(argc, argv);
10
+    MainWindow w;
11
+    w.resize(580,455);
12
+    w.show();
13
+
14
+    return a.exec();
15
+}

+ 254
- 0
mainwindow.cpp View File

@@ -0,0 +1,254 @@
1
+///
2
+/// Modifications:
3
+///     - 2015-01-13 [RAN] - Changed the quadraticFormulaCheck function to
4
+///                 prevent giving away the expression
5
+///     - 2015-06-09 [LAA] - Modified the graphics windwow so that you aren't
6
+///                 able to scroll
7
+
8
+#include "mainwindow.h"
9
+#include "ui_mainwindow.h"
10
+#include <QMessageBox>
11
+
12
+/// \fn MainWindow::MainWindow(QWidget *parent)
13
+/// \~English
14
+/// \brief Default constructor.
15
+/// \~Spanish
16
+/// \brief Constructor por defecto.
17
+///
18
+MainWindow::MainWindow(QWidget *parent) :
19
+    QMainWindow(parent),
20
+    ui(new Ui::MainWindow)
21
+{
22
+    quadraticFormulaCheck();
23
+
24
+    // set up mainWindow
25
+    ui->setupUi(this);
26
+    scene= new QGraphicsScene(this);
27
+    scene->setSceneRect(QRectF(QPointF(0,0), QPointF(0,0)));
28
+    ui->MainView->setScene(scene);
29
+    ui->MainView->setAlignment((Qt::AlignLeft | Qt::AlignTop));
30
+    ui->MainView->resize(580,345);
31
+    ui->MainView->move(0,0);
32
+    ui->MainView->setEnabled(false);
33
+
34
+    // set lables and buttons
35
+    ui->alabel->move(10,360);
36
+    ui->alineEdit->move(25,358);
37
+    ui->blabel->move(85,360);
38
+    ui->blineEdit->move(100,358);
39
+    ui->clabel->move(160,360);
40
+    ui->clineEdit->move(175,358);
41
+    ui->RunPushButton->move(10,385);
42
+    ui->retryButton->move(180,385);
43
+    ui->RunPushButton->setEnabled(false);
44
+
45
+    frogger = new frog;
46
+    globalTimer = new QTimer;
47
+    scene->addWidget(frogger);
48
+
49
+
50
+}
51
+
52
+/// \fn MainWindow::~MainWindow()
53
+/// \~English
54
+/// \brief Default destructor
55
+/// \~Spanish
56
+/// \brief Destructor por defecto
57
+///
58
+MainWindow::~MainWindow()
59
+{
60
+    delete ui;
61
+    delete scene;
62
+}
63
+
64
+/// \fn void MainWindow::quadraticFormulaCheck()
65
+/// \~English
66
+/// \brief Function that uses an array of values to determine
67
+///  if the equation written by the student is correct.
68
+/// \~Spanish
69
+/// \brief Funcion que utiliza un arreglo de valores para
70
+///  determinar si la ecuacion que escribio el estudiante
71
+///  esta correcta.
72
+///
73
+void MainWindow::quadraticFormulaCheck()
74
+{
75
+    float resultFromFunction;
76
+    bool pass = true;
77
+    float values[] = {357 , -1000 , 698 , 1.4804781099 , 748 , -392 , 51 , 0.28391805554 ,
78
+        689 , -689 , 172 , 0.519048482944 , 90 , 521 , 751 , -2.71178575308 , 5 , 107 ,
79
+        465 , -6.0642692054 , 1609 , -983 , 150 , 0.314734649792 , 273 , 496 , 224 ,
80
+        -0.839700867988 , 2 , 91 , 920 , -15.1630045473 , 48 , 300 , 463 , -2.77889067238 ,
81
+        852 , 907 , 241 , -0.510947439149};
82
+
83
+    float valuesForMinus[] = {129 , -486 , 456 , 1.76744186047 , 384 , 980 , 625 , -1.30208333333 ,
84
+        270 , -904 , 755 , 1.59515823795 , 67 , -450 , 752 , 3.12650485528 , 98 , 506 , 651 ,
85
+        -2.72985550047 , 38 , -373 , 901 , 4.29396930804 , 273 , -282 , 72 , 0.461538461538 ,
86
+        225 , -889 , 874 , 1.84 , 8 , 136 , 522 , -11.1457513111 , 5 , 77 , 214 , -11.760788100};
87
+
88
+    float a, b, c, expected;
89
+
90
+    //Verifying if the equation written by the student is correct
91
+    for (int i = 0; i < 40 && pass; i+=4){
92
+        a        = values[i];
93
+        b        = values[i+1];
94
+        c        = values[i+2];
95
+        expected = values[i+3];
96
+
97
+        // firstX = (((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a));
98
+        resultFromFunction = frogger->QuadraticPlus(a,b,c);
99
+
100
+        if( fabs(resultFromFunction - expected) > 0.00001) {
101
+            pass = false;
102
+        }
103
+    }
104
+    if(!pass){
105
+        QMessageBox::information(this, "Error", "La funcion cuadratica esta mal escrita!");
106
+        exit(1);
107
+    }
108
+
109
+    //Verifying if the equation written by the student is correct
110
+    for (int i = 0; i < 40 && pass; i+=4){
111
+        a        = valuesForMinus[i];
112
+        b        = valuesForMinus[i+1];
113
+        c        = valuesForMinus[i+2];
114
+        expected = valuesForMinus[i+3];
115
+
116
+        // firstX = (((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a));
117
+        resultFromFunction = frogger->QuadraticMinus(a,b,c);
118
+
119
+        if( fabs(resultFromFunction - expected) > 0.00001) {
120
+            pass = false;
121
+        }
122
+    }
123
+    if(!pass){
124
+        QMessageBox::information(this, "Error", "La funcion cuadratica esta mal escrita!");
125
+        exit(1);
126
+    }
127
+}
128
+
129
+/// \fn void on_RunPushButton_clicked()
130
+/// \~English
131
+/// \brief Function that is invoked when the jump button is pressed,
132
+///  frog jumps to calculated location.
133
+/// \~Spanish
134
+/// \brief Funcion que se invoca cuando el boton de "jump" es presionado,
135
+///  el sapo brinca a la localizacion calculada.
136
+///
137
+void MainWindow::on_RunPushButton_clicked()
138
+{
139
+    int a = 0;
140
+    int b = 0;
141
+    int c = 0;
142
+    int det = 0;
143
+    a = (ui->alineEdit->text().toInt());
144
+    b = (ui->blineEdit->text().toInt());
145
+    c = (ui->clineEdit->text().toInt());
146
+
147
+    det = (pow(b,2) - (4*a*c));
148
+
149
+    if(a > 0){
150
+        QMessageBox::information(this, "Error", "La parabola abre hacia arriba y por lo tanto el sapo no brincara");
151
+        ui->alineEdit->clear();
152
+        ui->blineEdit->clear();
153
+        ui->clineEdit->clear();
154
+    }
155
+    else if(a == 0){
156
+        QMessageBox::information(this, "Error", "No hay parabola y por lo tanto el sapo no brincara");
157
+        ui->alineEdit->clear();
158
+        ui->blineEdit->clear();
159
+        ui->clineEdit->clear();
160
+    }
161
+    else{
162
+        if(det < 0){
163
+            QMessageBox::information(this, "Error", "No tiene intercepto y por lo tanto el sapo no brincara");
164
+            ui->alineEdit->clear();
165
+            ui->blineEdit->clear();
166
+            ui->clineEdit->clear();
167
+        }
168
+        else if(det == 0){
169
+            QMessageBox::information(this, "Error", "El vertice esta en el intercepto y por lo tanto el sapo no brincara");
170
+            ui->alineEdit->clear();
171
+            ui->blineEdit->clear();
172
+            ui->clineEdit->clear();
173
+        }
174
+        else{
175
+            frogger->run(a, b, c);
176
+            ui->RunPushButton->setEnabled(false);
177
+            ui->alineEdit->clear();
178
+            ui->blineEdit->clear();
179
+            ui->clineEdit->clear();
180
+        }
181
+    }
182
+
183
+
184
+}
185
+
186
+/// \fn void on_retryButton_clicked()
187
+/// \~English
188
+/// \brief Function that is invoked when the reset button is pressed,
189
+///  returns the window to its original state.
190
+/// \~Spanish
191
+/// \brief Funcion que se invoca cuando el boton de "reset" es presionado,
192
+///  devuelve la ventana a su estado original.
193
+///
194
+void MainWindow::on_retryButton_clicked()
195
+{
196
+    frogger->reset();
197
+}
198
+
199
+/// \fn MainWindow::on_alineEdit_textChanged(QString &arg1)
200
+/// \~English
201
+/// \brief Function that is invoked when the text is changed in the
202
+///  alineEdit, enables jump buttton if the other line edits aren't empty.
203
+/// \~Spanish
204
+/// \brief Funcion que se invoca cuando el texto dentro de alineEdit
205
+///  cambia, permite que el button de "jump" sea presionado si los otros
206
+///  "line edits" no estan vacios.
207
+///
208
+void MainWindow::on_alineEdit_textChanged()
209
+{
210
+    if(ui->alineEdit->text() != "" && ui->blineEdit->text() != "" && ui->clineEdit->text() != "" ){
211
+        ui->RunPushButton->setEnabled(true);
212
+    }
213
+    else{
214
+        ui->RunPushButton->setEnabled(false);
215
+    }
216
+}
217
+
218
+/// \fn MainWindow::on_blineEdit_textChanged(QString &arg1)
219
+/// \~English
220
+/// \brief Function that is invoked when the text is changed in the
221
+///  alineEdit, enables jump buttton if the other line edits aren't empty.
222
+/// \~Spanish
223
+/// \brief Funcion que se invoca cuando el texto dentro de alineEdit
224
+///  cambia, permite que el button de "jump" sea presionado si los otros
225
+///  "line edits" no estan vacios.
226
+///
227
+void MainWindow::on_blineEdit_textChanged()
228
+{
229
+    if(ui->alineEdit->text() != "" && ui->blineEdit->text() != "" && ui->clineEdit->text() != "" ){
230
+        ui->RunPushButton->setEnabled(true);
231
+    }
232
+    else{
233
+        ui->RunPushButton->setEnabled(false);
234
+    }
235
+}
236
+
237
+/// \fn MainWindow::on_clineEdit_textChanged(QString &arg1)
238
+/// \~English
239
+/// \brief Function that is invoked when the text is changed in the
240
+///  alineEdit, enables jump buttton if the other line edits aren't empty.
241
+/// \~Spanish
242
+/// \brief Funcion que se invoca cuando el texto dentro de alineEdit
243
+///  cambia, permite que el button de "jump" sea presionado si los otros
244
+///  "line edits" no estan vacios.
245
+///
246
+void MainWindow::on_clineEdit_textChanged()
247
+{
248
+    if(ui->alineEdit->text() != "" && ui->blineEdit->text() != "" && ui->clineEdit->text() != "" ){
249
+        ui->RunPushButton->setEnabled(true);
250
+    }
251
+    else{
252
+        ui->RunPushButton->setEnabled(false);
253
+    }
254
+}

+ 106
- 0
mainwindow.h View File

@@ -0,0 +1,106 @@
1
+ #ifndef MAINWINDOW_H
2
+#define MAINWINDOW_H
3
+
4
+#include <QMainWindow>
5
+#include <QGraphicsScene>
6
+#include <QTimer>
7
+#include "frog.h"
8
+
9
+namespace Ui {
10
+    class MainWindow;
11
+}
12
+
13
+class MainWindow : public QMainWindow
14
+{
15
+    Q_OBJECT
16
+
17
+public:
18
+    /// \fn MainWindow::MainWindow(QWidget *parent)
19
+    /// \~English
20
+    /// \brief Default constructor.
21
+    /// \~Spanish
22
+    /// \brief Constructor por defecto.
23
+    ///
24
+    explicit MainWindow(QWidget *parent = 0);
25
+
26
+    /// \fn MainWindow::~MainWindow()
27
+    /// \~English
28
+    /// \brief Default destructor
29
+    /// \~Spanish
30
+    /// \brief Destructor por defecto
31
+    ///
32
+    ~MainWindow();
33
+
34
+    /// \fn void MainWindow::quadraticFormulaCheck()
35
+    /// \~English
36
+    /// \brief Function that uses an array of values to determine
37
+    ///  if the equation written by the student is correct.
38
+    /// \~Spanish
39
+    /// \brief Funcion que utiliza un arreglo de valores para
40
+    ///  determinar si la ecuacion que escribio el estudiante
41
+    ///  esta correcta.
42
+    ///
43
+    void quadraticFormulaCheck();
44
+
45
+private slots:
46
+    /// \fn void on_RunPushButton_clicked()
47
+    /// \~English
48
+    /// \brief Function that is invoked when the jump button is pressed,
49
+    ///  frog jumps to calculated location.
50
+    /// \~Spanish
51
+    /// \brief Funcion que se invoca cuando el boton de "jump" es presionado,
52
+    ///  el sapo brinca a la localizacion calculada.
53
+    ///
54
+    void on_RunPushButton_clicked();
55
+
56
+    /// \fn void on_retryButton_clicked()
57
+    /// \~English
58
+    /// \brief Function that is invoked when the reset button is pressed,
59
+    ///  returns the window to its original state.
60
+    /// \~Spanish
61
+    /// \brief Funcion que se invoca cuando el boton de "reset" es presionado,
62
+    ///  devuelve la ventana a su estado original.
63
+    ///
64
+    void on_retryButton_clicked();
65
+
66
+    /// \fn MainWindow::on_alineEdit_textChanged(QString &arg1)
67
+    /// \~English
68
+    /// \brief Function that is invoked when the text is changed in the
69
+    ///  alineEdit, enables jump buttton if the other line edits aren't empty.
70
+    /// \~Spanish
71
+    /// \brief Funcion que se invoca cuando el texto dentro de alineEdit
72
+    ///  cambia, permite que el button de "jump" sea presionado si los otros
73
+    ///  "line edits" no estan vacios.
74
+    ///
75
+    void on_alineEdit_textChanged();
76
+
77
+    /// \fn MainWindow::on_blineEdit_textChanged(QString &arg1)
78
+    /// \~English
79
+    /// \brief Function that is invoked when the text is changed in the
80
+    ///  alineEdit, enables jump buttton if the other line edits aren't empty.
81
+    /// \~Spanish
82
+    /// \brief Funcion que se invoca cuando el texto dentro de alineEdit
83
+    ///  cambia, permite que el button de "jump" sea presionado si los otros
84
+    ///  "line edits" no estan vacios.
85
+    ///
86
+    void on_blineEdit_textChanged();
87
+
88
+    /// \fn MainWindow::on_clineEdit_textChanged(QString &arg1)
89
+    /// \~English
90
+    /// \brief Function that is invoked when the text is changed in the
91
+    ///  alineEdit, enables jump buttton if the other line edits aren't empty.
92
+    /// \~Spanish
93
+    /// \brief Funcion que se invoca cuando el texto dentro de alineEdit
94
+    ///  cambia, permite que el button de "jump" sea presionado si los otros
95
+    ///  "line edits" no estan vacios.
96
+    ///
97
+    void on_clineEdit_textChanged();
98
+
99
+private:
100
+    Ui::MainWindow *ui;
101
+    QGraphicsScene*scene;
102
+    QTimer *globalTimer;
103
+    frog *frogger;
104
+};
105
+
106
+#endif // MAINWINDOW_H

+ 155
- 0
mainwindow.ui View File

@@ -0,0 +1,155 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<ui version="4.0">
3
+ <class>MainWindow</class>
4
+ <widget class="QMainWindow" name="MainWindow">
5
+  <property name="geometry">
6
+   <rect>
7
+    <x>0</x>
8
+    <y>0</y>
9
+    <width>436</width>
10
+    <height>373</height>
11
+   </rect>
12
+  </property>
13
+  <property name="windowTitle">
14
+   <string>MainWindow</string>
15
+  </property>
16
+  <widget class="QWidget" name="centralWidget">
17
+   <widget class="QGraphicsView" name="MainView">
18
+    <property name="geometry">
19
+     <rect>
20
+      <x>10</x>
21
+      <y>11</y>
22
+      <width>381</width>
23
+      <height>231</height>
24
+     </rect>
25
+    </property>
26
+    <property name="focusPolicy">
27
+     <enum>Qt::NoFocus</enum>
28
+    </property>
29
+    <property name="verticalScrollBarPolicy">
30
+     <enum>Qt::ScrollBarAlwaysOff</enum>
31
+    </property>
32
+    <property name="horizontalScrollBarPolicy">
33
+     <enum>Qt::ScrollBarAlwaysOff</enum>
34
+    </property>
35
+   </widget>
36
+   <widget class="QPushButton" name="RunPushButton">
37
+    <property name="geometry">
38
+     <rect>
39
+      <x>20</x>
40
+      <y>280</y>
41
+      <width>114</width>
42
+      <height>32</height>
43
+     </rect>
44
+    </property>
45
+    <property name="text">
46
+     <string>Jump</string>
47
+    </property>
48
+   </widget>
49
+   <widget class="QLabel" name="alabel">
50
+    <property name="geometry">
51
+     <rect>
52
+      <x>10</x>
53
+      <y>250</y>
54
+      <width>21</width>
55
+      <height>16</height>
56
+     </rect>
57
+    </property>
58
+    <property name="text">
59
+     <string>a: </string>
60
+    </property>
61
+   </widget>
62
+   <widget class="QLineEdit" name="alineEdit">
63
+    <property name="geometry">
64
+     <rect>
65
+      <x>30</x>
66
+      <y>250</y>
67
+      <width>31</width>
68
+      <height>22</height>
69
+     </rect>
70
+    </property>
71
+   </widget>
72
+   <widget class="QLabel" name="blabel">
73
+    <property name="geometry">
74
+     <rect>
75
+      <x>110</x>
76
+      <y>250</y>
77
+      <width>21</width>
78
+      <height>16</height>
79
+     </rect>
80
+    </property>
81
+    <property name="text">
82
+     <string>b:</string>
83
+    </property>
84
+   </widget>
85
+   <widget class="QLineEdit" name="blineEdit">
86
+    <property name="geometry">
87
+     <rect>
88
+      <x>130</x>
89
+      <y>250</y>
90
+      <width>31</width>
91
+      <height>22</height>
92
+     </rect>
93
+    </property>
94
+   </widget>
95
+   <widget class="QLineEdit" name="clineEdit">
96
+    <property name="geometry">
97
+     <rect>
98
+      <x>230</x>
99
+      <y>250</y>
100
+      <width>31</width>
101
+      <height>22</height>
102
+     </rect>
103
+    </property>
104
+   </widget>
105
+   <widget class="QLabel" name="clabel">
106
+    <property name="geometry">
107
+     <rect>
108
+      <x>210</x>
109
+      <y>250</y>
110
+      <width>21</width>
111
+      <height>16</height>
112
+     </rect>
113
+    </property>
114
+    <property name="text">
115
+     <string>c:</string>
116
+    </property>
117
+   </widget>
118
+   <widget class="QPushButton" name="retryButton">
119
+    <property name="geometry">
120
+     <rect>
121
+      <x>210</x>
122
+      <y>280</y>
123
+      <width>114</width>
124
+      <height>32</height>
125
+     </rect>
126
+    </property>
127
+    <property name="text">
128
+     <string>Retry</string>
129
+    </property>
130
+   </widget>
131
+  </widget>
132
+  <widget class="QMenuBar" name="menuBar">
133
+   <property name="geometry">
134
+    <rect>
135
+     <x>0</x>
136
+     <y>0</y>
137
+     <width>436</width>
138
+     <height>21</height>
139
+    </rect>
140
+   </property>
141
+  </widget>
142
+  <widget class="QToolBar" name="mainToolBar">
143
+   <attribute name="toolBarArea">
144
+    <enum>TopToolBarArea</enum>
145
+   </attribute>
146
+   <attribute name="toolBarBreak">
147
+    <bool>false</bool>
148
+   </attribute>
149
+  </widget>
150
+  <widget class="QStatusBar" name="statusBar"/>
151
+ </widget>
152
+ <layoutdefault spacing="6" margin="11"/>
153
+ <resources/>
154
+ <connections/>
155
+</ui>

BIN
resources/Frogger1.png View File


BIN
resources/Frogger2.png View File


BIN
resources/Frogger3.png View File


BIN
resources/Nenufar1.png View File


BIN
resources/Nenufar2.png View File


BIN
resources/Nenufar3.png View File


BIN
resources/Nenufar4.png View File


BIN
resources/background.jpg View File


+ 12
- 0
resources/images.qrc View File

@@ -0,0 +1,12 @@
1
+<RCC>
2
+    <qresource prefix="/images">
3
+        <file>Frogger1.png</file>
4
+        <file>Frogger2.png</file>
5
+        <file>Nenufar4.png</file>
6
+        <file>Nenufar3.png</file>
7
+        <file>Nenufar2.png</file>
8
+        <file>Nenufar1.png</file>
9
+        <file>background.jpg</file>
10
+        <file>Frogger3.png</file>
11
+    </qresource>
12
+</RCC>