Skip to content

Commit

Permalink
feat (small challenges): new small challenges static
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Apr 20, 2021
1 parent ac0e683 commit f2200e7
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit f2200e7

Please sign in to comment.