The final boss has been defeated!

--Originally published at Programming Path

At last our final project is finished! It was very interesting to make the code, and to make it run properly. My partner Sergio Iriarte and I decided to program a little game, this was because we both like video games and it sound fun to make a game. It felt more like an achievement.

We came up with the idea of programming the game Battleship. Sergio knows how to program in Java after taking some classes on past years, so we decided to do the game in Java. The reasons were because it is a more simple way of programming, is better organized and much easier to use than C++. And of course he was very patient with me because I am new to this thing they call programming.

After making the decision, I had to install eclipse, it was a total disaster because my computer was very slow, but in the end we could defeat this troublemaker called Battleship.

Here is the code:

Final1final2final3

And here is how we see it when running:

  • * means the user have missed.
  • ~ means the user did not hit that coordinate.
  • X means the user has hit a ship.

Every round, the game gives the user a hint about where could a ship be.

final4

So this is it. We finally finished the project. Just in time for this post ?

 


Dovahkiin, Dovahkiin, naal ok zin los vahriin.. (#WSQ09)

--Originally published at Programming Path

The assignment of #WSQ09 was the next one:

So for this assignment I would like to see you create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line

This for sure was a new topic. It was thanks to Ken’s Disciple 01‘s blog that I could understand this task.

First I needed to make a text file (.txt) so I wrote a Skyrim quote. It is from an ancient dragon and I got attached to him because it was the only friendly dragon, but anyway here is the text:

skyrim

Then we had to make the program open the file and count how many characters and lines does it has. Then print it out.

WSQ09

Thanks for reading.

 


Survey! (Quiz week 14)

--Originally published at Programming Path

For this quiz we had to do an evaluation of our teacher Ken. I really want to thank him for the new experience he gave us of his way of teaching. I actually like that method because it helps me with my will force. Not only that, it helps me realize how responsible I am.

Thanks Ken Bauer.

It’s still not over, but I will give my best.

I want to share the song I am listening right now. It is The Bay from Metronomy.


Lots of Problems (Quiz week 9)

--Originally published at Programming Path

This quiz was veeeery long. There were 10 problems, but we only had to do 8 problems.

1. Escribe el función distancia cual recibe 4 números (x1, y1, x2, y2) cuales representan dos puntos en espacio (x1,y1) y (x2,y2). El método debe regresar la distancia entre los dos puntos. Recuerda que el valor cuadrada del hipotenusa del triangulo es igual que la suma de las cuadradas de los otro dos lados del triangulo (the hypotenuse squared is equal to the sum of the squares of the other two sides).

Quiz9

2. (5 puntos) Escribe un función que se llama triangulo cual recibe un parámetro size y imprime un triangulo derecho como el siguiente. El renglón mas grande debe llevar size numero de “T”. SOLO imprime los “T”s y los endlines. Nota que no hay characteres (espacios) a la derecha de los T’s. Debe usar un ciclo “for” para controlar el repetición.

PQ2

 

3. Escribe la función factorial cual recibe un entero “x” y regresa el valor de x! Recuerda que 0! = 1, 1! = 1, 2! = 2, 3!= 6, 4! = 24, etc. Para los de Python: NO PUEDES usar el factorial como parte del module “math”

PQ3

4. Escribe una función que se llama promedio_lista que recibe un parámetro (una lista (Python) o arreglo/Vector de C++) de valores float y regresa como float el promedio de los números en la lista.

PQ4

5. Escribe una función que se llama smallest_of_four cual recibe cuatro valores float como parametros y regresa el minimo (más pequeño) de los valores. Ojo: puede recibir unos valores iguales.

Click to view slideshow.

6. Escribe una función que se llama fibonacci cual recibe un número n (puedes dar por cuenta que valor mayor o igual que cero) y regresa y valor correspondiente del serie de fibonacci,

PQ6
PQ7.png
PQ10
?
Continue reading "Lots of Problems (Quiz week 9)"

Distance (Quiz week 9)

--Originally published at Programming Path

The assignment of the quiz was to ask for two coordinates and calculate the distance between them. It needed to have floats and a function as well.

This problem was very easy, because in school they made me calculate the distance a lot of times. I only add the math library (<cmath>) because I elevate to the power and resolve a square root.

Here is the code:

Quiz9

Thanks for reading.


THE List -.-‘! (WSQ07)

--Originally published at Programming Path

What a way to give me stress! This task gave me a lot of problems, because it was the first time for me to use arrays, and I looked it in the textbook of the course but didn’t help that much. Then I looked for arrays in the net. I found a tutorial of arrays that explains what are they for and how to use them.

Anyway, the task was this:

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

We could use arrays or vectors. I didn’t know neither of those, but is never too late to try learn something new. After I understood a little about how do the arrays work I started writing my code. Everything was fine until I needed the standard deviation. To be honest, I did not know what was the standard deviation until this task, I don’t even remember seeing it in elementary school, or middle school, so I had to look for the formula. Here is the formula:

formula
by Kaela Parkhouse

After finding the formula, it gave me a lot more trouble because I had to assign more variables. And that is how I ended up with this code. Not vary proud of this:

#include <iostream>
#include <cmath>
using namespace std;

float total, av, stde, s;
float StandardD (float,float,float,float,float,float,float,float,float,float);

int main () {
float a, b, c, d, e, f, g, h, i, j;
float foo [] = {a, b, c, d, e, f, g, h, i, j};
cout << “Enter 10 numbers. I will give you the total, average and stadard deviation of them.” << endl;
cout << endl << “Number 1: “;
cin >> a;
cout << endl

WSQ07
Continue reading "THE List -.-‘! (WSQ07)"

Fibonacci is awesome!

--Originally published at Programming Path

My mom always told me about the Fibonacci patterns in nature and how beautiful they are as well that it is so interesting that it’s all mathematics!

I’ve found a TED talk that explain in a very easy way to understand the Fibonacci series. I recommend you to watch it.

The quiz today was precisely of doing a function that gives you a Fibonacci number. What I did was to ask the user a number, and I return the Fibonacci number, or at least that was my intention of asking, but I think that my question isn’t the correct one.

*Just a note. The first Fibonacci numbers are the next one:

0  1  1  2  3  5  8  13  21  34  55  89…

Here is my code:

quiz6

And the result was this:

Enter the number of numbers you want to know of Fibonacci numbers: 10
fibonacci number: 55.

Another try:

Enter the number of numbers you want to know of Fibonacci numbers: 2
fibonacci number: 1.

Thanks for reading.


WSQ06.Factorial-lml.

--Originally published at Programming Path

More loops!! Haha I actually forgot how to do some loops, but thanks to Sergio, I could remember that exist the loop of DO.

The assignment  was to ask the user a non-negative number to find its factorial number. It doesn’t specify if it has to be done as a function or not, but I decided to do it as a function.

Here is the code:

wsq06

It wasn’t that hard, but like I said before, I forgot that I could do a loop with DO.

Thanks for reading.