diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..b39114fc3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Jupyter Notebook +.ipynb_checkpoints diff --git a/README.md b/README.md index 773685edf..1f945ec28 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Todos os exemplos no diretório `notebook` são preparados para o ambiente Jupyt # Acionando os Notebooks via Binder * Última versão testada e estável: - [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.0.0) + [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/v1.1.0) * Última versão disponível: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/santanche/component2learn/master) diff --git a/binder/environment.yml b/binder/environment.yml new file mode 100644 index 000000000..34564848f --- /dev/null +++ b/binder/environment.yml @@ -0,0 +1,5 @@ +name: beakerx +channels: + - conda-forge +dependencies: + - numpy diff --git a/binder/apt.txt b/binder/old/apt.txt similarity index 100% rename from binder/apt.txt rename to binder/old/apt.txt diff --git a/binder/old/postBuild b/binder/old/postBuild new file mode 100644 index 000000000..75bd4d9da --- /dev/null +++ b/binder/old/postBuild @@ -0,0 +1,23 @@ +#!/bin/bash + +############################################################### +# jupyter/jupyterlab extensions/kernels # +############################################################### + +# Beaker installation and extension setup +beakerx install +jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build +jupyter labextension install beakerx-jupyterlab --no-build + +# Table of contents Jupyter Lab Extension +jupyter labextension install @jupyterlab/toc --no-build + +# Git Jupyter/Lab extension +jupyter labextension install @jupyterlab/git --no-build +jupyter serverextension enable --py jupyterlab_git + +# Github Jupyter Lab extension +jupyter labextension install @jupyterlab/github --no-build + +# Building everything up for jupyterlab extensions +jupyter lab build diff --git a/binder/requirements.txt b/binder/old/requirements.txt similarity index 100% rename from binder/requirements.txt rename to binder/old/requirements.txt diff --git a/binder/start b/binder/old/start similarity index 100% rename from binder/start rename to binder/old/start diff --git a/binder/postBuild b/binder/postBuild index 75bd4d9da..c74305017 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,23 +1 @@ -#!/bin/bash - -############################################################### -# jupyter/jupyterlab extensions/kernels # -############################################################### - -# Beaker installation and extension setup -beakerx install -jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build -jupyter labextension install beakerx-jupyterlab --no-build - -# Table of contents Jupyter Lab Extension -jupyter labextension install @jupyterlab/toc --no-build - -# Git Jupyter/Lab extension -jupyter labextension install @jupyterlab/git --no-build -jupyter serverextension enable --py jupyterlab_git - -# Github Jupyter Lab extension -jupyter labextension install @jupyterlab/github --no-build - -# Building everything up for jupyterlab extensions -jupyter lab build +conda install beakerx \ No newline at end of file diff --git a/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-1-single-class-checkpoint.ipynb b/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-1-single-class-checkpoint.ipynb deleted file mode 100644 index a4c061828..000000000 --- a/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-1-single-class-checkpoint.ipynb +++ /dev/null @@ -1,571 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Componentes" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Componente `GeometricProgression`\n", - "\n", - "Gera uma progressão geométrica a partir de um valor `inicial` e de uma `razão`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `ISequence`\n", - "\n", - "Percorre os elementos da razão em sequência. Métodos:\n", - "* `first` - se desloca para (ou calcula) o primeiro elemento da sequência e o retorna\n", - "* `next` - se desloca para (ou calcula) o pŕoximo elemento da sequência e o retorna" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.ISequence" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface ISequence {\n", - " public int first();\n", - " public int next();\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `IGeometricProgressionProperties`\n", - "\n", - "Propriedades de uma progressão geométrica.\n", - "\n", - "Métodos `get` e `set` para as propriedades:\n", - "* `initial` - valor inicial da progressão\n", - "* `ratio` - razão da progressão" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IGeometricProgressionProperties" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IGeometricProgressionProperties {\n", - " public int getInitial();\n", - " public void setInitial(int initial);\n", - " \n", - " public int getRatio();\n", - " public void setRatio(int ratio);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `IGeometricProgression`\n", - "\n", - "Unifica as duas interfaces anteriores." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IGeometricProgression" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IGeometricProgression\n", - " extends ISequence, IGeometricProgressionProperties {\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Classe `GeometricProgression`\n", - "\n", - "Gera uma **Progressão Geométrica** a partir de um valor inicial (`initial`) e de uma razão (`ratio`)." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.GeometricProgression" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class GeometricProgression implements IGeometricProgression {\n", - " private int initial,\n", - " ratio;\n", - " private int current;\n", - " \n", - " public GeometricProgression() {\n", - " initial = 1;\n", - " ratio = 2;\n", - " current = initial;\n", - " }\n", - " \n", - " public int getInitial() {\n", - " return initial;\n", - " }\n", - " \n", - " public void setInitial(int initial) {\n", - " this.initial = initial;\n", - " }\n", - " \n", - " public int getRatio() {\n", - " return ratio;\n", - " }\n", - " \n", - " public void setRatio(int ratio) {\n", - " this.ratio = ratio;\n", - " }\n", - " \n", - " public int first() {\n", - " current = initial;\n", - " return current;\n", - " }\n", - " \n", - " public int next() {\n", - " current *= ratio;\n", - " return current;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exemplo de uso do Componente" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Progressão Geométrica: 1, 2, 4, 8, 16, " - ] - }, - { - "data": { - "text/plain": [ - "null" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "IGeometricProgression gp = new GeometricProgression();\n", - "gp.setInitial(1);\n", - "gp.setRatio(2);\n", - "System.out.print(\"Progressão Geométrica: \");\n", - "int value = gp.first();\n", - "for (int g = 1; g <= 5; g++) {\n", - " System.out.print(value + \", \");\n", - " value = gp.next();\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Componente `BarChart`\n", - "\n", - "Apresenta um diagrama de barras no console a partir de uma sequência de números. A sequência é produzida por um componente a ele conectado." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `IChart`\n", - "\n", - "Dispara a apresentação do diagrama a partir do método `plot()`." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IChart" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IChart {\n", - " public void plot();\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `IBarChartProperties`\n", - "\n", - "Propriedades para configurar um gráfico de barras.\n", - "\n", - "Métodos `get` e `set` para as propriedades:\n", - "* `filled` - define se o gráfico será preenchido\n", - "* `character` - caractere que será usado para plotar o gráfico\n", - "* `n` - número de barras que serão apresentadas" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IBarChartProperties" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IBarChartProperties {\n", - " public boolean isFilled();\n", - " public void setFilled(boolean filled);\n", - "\n", - " public char getCharacter();\n", - " public void setCharacter(char character);\n", - "\n", - " public int getN();\n", - " public void setN(int n);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface Requerida `IRSequence`\n", - "\n", - "Interface que requer outra interface `ISequence`. Método:\n", - "* `connect` - realiza a conexão com um componente que tem a interface ISequence" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IRSequence" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IRSequence {\n", - " public void connect(ISequence sequence);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Interface `IBarChart`\n", - "\n", - "Unifica as três interfaces anteriores." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IBarChart" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IBarChart\n", - " extends IChart, IBarChartProperties, IRSequence {\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Classe `BarChart`\n", - "\n", - "Implementa a apresentação de um gráfico de barras." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.BarChart" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class BarChart implements IBarChart {\n", - " private boolean filled;\n", - " private char character;\n", - " private int n;\n", - " \n", - " private ISequence sequence;\n", - " \n", - " public BarChart() {\n", - " filled = true;\n", - " character = '*';\n", - " n = 3;\n", - " }\n", - "\n", - " public boolean isFilled() {\n", - " return filled;\n", - " }\n", - "\n", - " public void setFilled(boolean filled) {\n", - " this.filled = filled;\n", - " }\n", - "\n", - " public char getCharacter() {\n", - " return character;\n", - " }\n", - "\n", - " public void setCharacter(char character) {\n", - " this.character = character;\n", - " }\n", - "\n", - " public int getN() {\n", - " return n;\n", - " }\n", - "\n", - " public void setN(int n) {\n", - " this.n = n;\n", - " }\n", - "\n", - " public void connect(ISequence sequence) {\n", - " this.sequence = sequence;\n", - " }\n", - " \n", - " public void plot() {\n", - " if (sequence != null) {\n", - " int value = sequence.first();\n", - " for (int s = 1; s <= n; s++) {\n", - " for (int v = 1; v < value; v++)\n", - " System.out.print((filled) ? character : ' ');\n", - " System.out.println(character);\n", - " value = sequence.next();\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Aplicação Exemplo\n", - "Instancia os dois componentes (progressão geométrica e gráfico de barras), os conecta e dispara o processo de plotagem no componente do gráfico de barras." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "#\n", - "##\n", - "####\n", - "########\n", - "################\n" - ] - }, - { - "data": { - "text/plain": [ - "null" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "IGeometricProgression gp = new GeometricProgression();\n", - "gp.setInitial(1);\n", - "gp.setRatio(2);\n", - "\n", - "IBarChart bc = new BarChart();\n", - "bc.setFilled(true);\n", - "bc.setCharacter('#');\n", - "bc.setN(5);\n", - "\n", - "bc.connect(gp);\n", - "bc.plot();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercício do Gráfico de Segundo Grau\n", - "\n", - "## Função de segundo grau\n", - "\n", - "Escreva uma classe `SegundoGrau` cujos objetos produzam valores de uma função de segundo grau." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Plotagem de parábola\n", - "\n", - "Escreva um programa que conecte um objeto da classe `SegundoGrau` a um objeto da classe `Grafico` de forma que seja plotada uma parábola. Por conta do comportamento da classe `Grafico`, a parábola será plotada virada, ou seja eixos X e Y trocados." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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_152-release" - }, - "toc": { - "base_numbering": 1, - "nav_menu": {}, - "number_sections": false, - "sideBar": false, - "skip_h1_title": false, - "title_cell": "Table of Contents", - "title_sidebar": "Contents", - "toc_cell": false, - "toc_position": {}, - "toc_section_display": false, - "toc_window_display": false - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-2-multiple-classes-checkpoint.ipynb b/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-2-multiple-classes-checkpoint.ipynb deleted file mode 100644 index 9c2f9ffcf..000000000 --- a/labs/2021/02-dataflow_mvc/notebooks/.ipynb_checkpoints/components-chart-2-multiple-classes-checkpoint.ipynb +++ /dev/null @@ -1,597 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Componentes com Múltiplas Classes\n", - "\n", - "# Componente `MathSequence`" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.ISequence" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface ISequence {\n", - " public int first();\n", - " public int next();\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.ISeqInitialProperties" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface ISeqInitialProperties {\n", - " public int getInitial();\n", - " public void setInitial(int initial);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.ISeqRatioProperties" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface ISeqRatioProperties {\n", - " public int getRatio();\n", - " public void setRatio(int ratio);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IMathSequence" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IMathSequence\n", - " extends ISequence, ISeqInitialProperties {\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IMathRatioSequence" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IMathRatioSequence\n", - " extends IMathSequence, ISeqRatioProperties {\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.GeometricProgression" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class GeometricProgression implements IMathRatioSequence {\n", - " private int initial,\n", - " ratio;\n", - " private int current;\n", - " \n", - " public GeometricProgression() {\n", - " initial = 1;\n", - " ratio = 2;\n", - " current = initial;\n", - " }\n", - " \n", - " public int getInitial() {\n", - " return initial;\n", - " }\n", - " \n", - " public void setInitial(int initial) {\n", - " this.initial = initial;\n", - " }\n", - " \n", - " public int getRatio() {\n", - " return ratio;\n", - " }\n", - " \n", - " public void setRatio(int ratio) {\n", - " this.ratio = ratio;\n", - " }\n", - " \n", - " public int first() {\n", - " current = initial;\n", - " return current;\n", - " }\n", - " \n", - " public int next() {\n", - " current *= ratio;\n", - " return current;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.ArithmeticProgression" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class ArithmeticProgression implements IMathRatioSequence {\n", - " private int initial,\n", - " ratio;\n", - " private int current;\n", - " \n", - " public ArithmeticProgression() {\n", - " initial = 1;\n", - " ratio = 1;\n", - " current = initial;\n", - " }\n", - " \n", - " public int getInitial() {\n", - " return initial;\n", - " }\n", - " \n", - " public void setInitial(int initial) {\n", - " this.initial = initial;\n", - " }\n", - " \n", - " public int getRatio() {\n", - " return ratio;\n", - " }\n", - " \n", - " public void setRatio(int ratio) {\n", - " this.ratio = ratio;\n", - " }\n", - " \n", - " public int first() {\n", - " current = initial;\n", - " return current;\n", - " }\n", - " \n", - " public int next() {\n", - " current += ratio;\n", - " return current;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.Fibonacci" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class Fibonacci implements IMathSequence {\n", - " private int initialCurrent, initialNext;\n", - " private int current, next;\n", - " \n", - " public Fibonacci() {\n", - " initialCurrent = 0;\n", - " initialNext = 1;\n", - " current = 0;\n", - " next = 1;\n", - " }\n", - " \n", - " public int getInitial() {\n", - " return initialCurrent;\n", - " }\n", - " \n", - " public void setInitial(int initial) {\n", - " current = 0;\n", - " next = 1;\n", - " while (initial > current) {\n", - " int sum = current + next;\n", - " current = next;\n", - " next = sum;\n", - " }\n", - " initialCurrent = current;\n", - " initialNext = next;\n", - " }\n", - " \n", - " public int first() {\n", - " current = initialCurrent;\n", - " next = initialNext;\n", - " return current;\n", - " }\n", - " \n", - " public int next() {\n", - " int sum = current + next;\n", - " current = next;\n", - " next = sum;\n", - " return current;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Componente `BarChart`" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IChart" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IChart {\n", - " public void plot();\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IRSequence" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IRSequence {\n", - " public void connect(ISequence sequence);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IBarChartProperties" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IBarChartProperties {\n", - " public boolean isFilled();\n", - " public void setFilled(boolean filled);\n", - "\n", - " public int getN();\n", - " public void setN(int n);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.IBarChart" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public interface IBarChart\n", - " extends IChart, IRSequence, IBarChartProperties {\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.BarChart" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public abstract class BarChart implements IBarChart {\n", - " protected boolean filled;\n", - " protected int n;\n", - " \n", - " protected ISequence sequence;\n", - " \n", - " public BarChart() {\n", - " filled = true;\n", - " n = 3;\n", - " }\n", - "\n", - " public boolean isFilled() {\n", - " return filled;\n", - " }\n", - "\n", - " public void setFilled(boolean filled) {\n", - " this.filled = filled;\n", - " }\n", - "\n", - " public int getN() {\n", - " return n;\n", - " }\n", - "\n", - " public void setN(int n) {\n", - " this.n = n;\n", - " }\n", - "\n", - " public void connect(ISequence sequence) {\n", - " this.sequence = sequence;\n", - " }\n", - " \n", - " public abstract void plot();\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "com.twosigma.beaker.javash.bkrcdf00f98.ConsoleBarChart" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "public class ConsoleBarChart extends BarChart {\n", - " private char character;\n", - " \n", - " public ConsoleBarChart() {\n", - " super();\n", - " character = '*';\n", - " }\n", - "\n", - " public char getCharacter() {\n", - " return character;\n", - " }\n", - "\n", - " public void setCharacter(char character) {\n", - " this.character = character;\n", - " }\n", - "\n", - " public void plot() {\n", - " if (sequence != null) {\n", - " int value = sequence.first();\n", - " for (int s = 1; s <= n; s++) {\n", - " if (value > 0) {\n", - " for (int v = 1; v < value; v++)\n", - " System.out.print((filled) ? character : ' ');\n", - " System.out.print(character);\n", - " }\n", - " System.out.println();\n", - " value = sequence.next();\n", - " }\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Aplicação Exemplo" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Geometric Progression:\n", - "*\n", - "**\n", - "****\n", - "********\n", - "****************\n", - "\n", - "Fibonacci Sequence:\n", - "*\n", - "*\n", - "**\n", - "***\n", - "*****\n" - ] - }, - { - "data": { - "text/plain": [ - "null" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "System.out.println(\"Geometric Progression:\");\n", - "\n", - "IMathRatioSequence gp = new GeometricProgression();\n", - "gp.setInitial(1);\n", - "gp.setRatio(2);\n", - "\n", - "IBarChart bcg = new ConsoleBarChart();\n", - "bcg.setFilled(true);\n", - "bcg.setN(5);\n", - "\n", - "bcg.connect(gp);\n", - "bcg.plot();\n", - "\n", - "System.out.println(\"\\nFibonacci Sequence:\");\n", - "\n", - "IMathSequence fb = new Fibonacci();\n", - "fb.setInitial(1);\n", - "\n", - "IBarChart bcf = new ConsoleBarChart();\n", - "bcf.setFilled(true);\n", - "bcf.setN(5);\n", - "\n", - "bcf.connect(fb);\n", - "bcf.plot();" - ] - } - ], - "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_152-release" - }, - "toc": { - "base_numbering": 1, - "nav_menu": {}, - "number_sections": false, - "sideBar": false, - "skip_h1_title": false, - "title_cell": "Table of Contents", - "title_sidebar": "Contents", - "toc_cell": false, - "toc_position": {}, - "toc_section_display": false, - "toc_window_display": false - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/labs/2021/02-dataflow_mvc/notebooks/components-chart-1-single-class.ipynb b/labs/2021/02-dataflow_mvc/notebooks/components-chart-1-single-class.ipynb index 42530d7af..1242fb8d1 100644 --- a/labs/2021/02-dataflow_mvc/notebooks/components-chart-1-single-class.ipynb +++ b/labs/2021/02-dataflow_mvc/notebooks/components-chart-1-single-class.ipynb @@ -29,16 +29,16 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.ISequence" + "com.twosigma.beaker.javash.bkr685f263d.ISequence" ] }, - "execution_count": 12, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -65,16 +65,16 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IGeometricProgressionProperties" + "com.twosigma.beaker.javash.bkr685f263d.IGeometricProgressionProperties" ] }, - "execution_count": 13, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -100,16 +100,16 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IGeometricProgression" + "com.twosigma.beaker.javash.bkr685f263d.IGeometricProgression" ] }, - "execution_count": 14, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -137,7 +137,7 @@ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.GeometricProgression" + "com.twosigma.beaker.javash.bkr685f263d.GeometricProgression" ] }, "execution_count": 4, @@ -194,7 +194,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -210,7 +210,7 @@ "null" ] }, - "execution_count": 15, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -247,16 +247,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IChart" + "com.twosigma.beaker.javash.bkr685f263d.IChart" ] }, - "execution_count": 16, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -283,16 +283,16 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IBarChartProperties" + "com.twosigma.beaker.javash.bkr685f263d.IBarChartProperties" ] }, - "execution_count": 17, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -322,16 +322,16 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IRSequence" + "com.twosigma.beaker.javash.bkr685f263d.IRSequence" ] }, - "execution_count": 18, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -359,7 +359,7 @@ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.IBarChart" + "com.twosigma.beaker.javash.bkr685f263d.IBarChart" ] }, "execution_count": 9, @@ -390,7 +390,7 @@ { "data": { "text/plain": [ - "com.twosigma.beaker.javash.bkr4fd108a0.BarChart" + "com.twosigma.beaker.javash.bkr685f263d.BarChart" ] }, "execution_count": 10, @@ -502,40 +502,6 @@ "bc.connect(gp);\n", "bc.plot();" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Exercício do Gráfico de Segundo Grau\n", - "\n", - "## Função de segundo grau\n", - "\n", - "Escreva uma classe `SegundoGrau` cujos objetos produzam valores de uma função de segundo grau." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Plotagem de parábola\n", - "\n", - "Escreva um programa que conecte um objeto da classe `SegundoGrau` a um objeto da classe `Grafico` de forma que seja plotada uma parábola. Por conta do comportamento da classe `Grafico`, a parábola será plotada virada, ou seja eixos X e Y trocados." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {