diff --git a/README.md b/README.md index 0a0b7a1..b24dade 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Todos os exemplos no diretório `notebook` são preparados para o ambiente Jupyt ## Abrir branch específico em uma instância do [binderhub](https://github.com/jupyterhub/binderhub) * Última versão testada e estável: - [![launch @ mybinder.org][badge-jupyterlab-mybinder-org]](https://mybinder.org/v2/gh/santanche/java2learn/v1.1.3?urlpath=lab) + [![launch @ mybinder.org][badge-jupyterlab-mybinder-org]](https://mybinder.org/v2/gh/santanche/java2learn/v1.1.4?urlpath=lab) * Última versão disponível: [![launch @ mybinder.org][badge-jupyterlab-mybinder-org]](https://mybinder.org/v2/gh/santanche/java2learn/master?urlpath=lab) diff --git a/notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02-static.ipynb b/notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02-static.ipynb new file mode 100644 index 0000000..398c2ad --- /dev/null +++ b/notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02-static.ipynb @@ -0,0 +1,124 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "white-worcester", + "metadata": {}, + "source": [ + "# Small Challenges 2\n", + "\n", + "Tente descobrir o resultado de cada um dos programas abaixo, depois o execute para ver se confere com o que você supôs.\n", + "\n", + "## Parte 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "broadband-memorial", + "metadata": {}, + "outputs": [], + "source": [ + "public class Combinado {\n", + " private static int a = 0;\n", + " private int b = 0;\n", + " \n", + " public Combinado(int a, int b) {\n", + " this.a = a;\n", + " this.b = b;\n", + " }\n", + " \n", + " public void incrementa() {\n", + " a++;\n", + " b++;\n", + " System.out.println(\"a: \" + a + \"; b: \" + b);\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "special-swift", + "metadata": {}, + "outputs": [], + "source": [ + "Combinado c1 = new Combinado(5, 5),\n", + " c2 = new Combinado(7, 7);\n", + "\n", + "c1.incrementa();\n", + "c2.incrementa();\n", + "c1.incrementa();\n", + "c2.incrementa();" + ] + }, + { + "cell_type": "markdown", + "id": "greater-arabic", + "metadata": {}, + "source": [ + "# Parte 2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "crude-quantity", + "metadata": {}, + "outputs": [], + "source": [ + "public class Combinado {\n", + " private static int a = 0;\n", + " private int b = 0;\n", + " \n", + " public Combinado(int a, int b) {\n", + " this.a = a;\n", + " this.b = b;\n", + " }\n", + " \n", + " public void incrementa() {\n", + " a++;\n", + " b++;\n", + " System.out.println(\"a: \" + a + \"; b: \" + b);\n", + " }\n", + " \n", + " public static void variosIncrementos(int n) {\n", + " for (int v = 1; v <= n; v++)\n", + " this.incrementa();\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "civic-freight", + "metadata": {}, + "outputs": [], + "source": [ + "Combinado c1 = new Combinado(5, 5),\n", + " c2 = new Combinado(7, 7);\n", + "\n", + "c1.variosIncrementos(2);\n", + "c2.variosIncrementos(3);" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Java", + "language": "java", + "name": "java" + }, + "language_info": { + "codemirror_mode": "text/x-java", + "file_extension": ".java", + "mimetype": "", + "name": "Java", + "nbconverter_exporter": "", + "version": "1.8.0_121" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02.ipynb b/notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-03.ipynb similarity index 100% rename from notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02.ipynb rename to notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-03.ipynb