-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (small challenges): new small challenges static
- Loading branch information
Showing
3 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
notebooks/pt/c02oo-java/s10small-challenges/s01tarefa/small-challenges-02-static.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
File renamed without changes.