• Non ci sono risultati.

How to Install

N/A
N/A
Protected

Academic year: 2021

Condividi "How to Install"

Copied!
7
0
0

Testo completo

(1)

!" #

$ % &

EclipseUML by examples 2

' (

' (

How to Install

Class Diagram Example The Game of Life

' (

' (

Overview and how to install

Class Diagram Example The Game of Life

)* )* & & + ( + ( , ,

& + (

- . *+ (

* (/00... (

1* 1 + ( ( " . * *

2 3 . * 4 *

* + ( (

& 1 1 . 1 1 /

+ ( +

.* * ( 5

+ ( + ( +

.* *( 3 36 3 $

( 3

(2)

EclipseUML by examples 5

7 . + (

7 . + (

* (/00... ( 0 . 01 0 89(

. + ( 44 . *- &

( " :;" 44". ! ( ( " :;" 44" 8" < (

. + (

( " =4 4 !44 !9

- & 3 ( ( " :;

/> (

> > > (

9 "9 ( " =4 4 !44 !9

( 1 - * * -

EclipseUML by examples 6

' (

' (

Overview and how to install

Class Diagram Example

The Game of Life

: +8 (

: +8 (

* 1 . ( *1 * ( -

( >( > =4 4> >

> : > : +8 ( > : +8 ( *

* .

* (

: +8 (

: +8 (

(3)

EclipseUML by examples 9

' (

' (

Overview and how to install Class Diagram Example

The Game of Life

EclipseUML by examples 10

' 1 ' 1

* 1 . 8 1

. .* * ( 1* &(

? + + @( 9

* . ( $-3

(- * $-+ ( -3

* .*

* (/00... ( 0 0

' 1* A 1

' 1* A 1 1 1

1 ( - 1 B C < *

$ D$ 8 1 - -

$

* . $-( < B

* . $- * B (-

+ * * * *$ *

1* * -

((- ( 1 * 3. * $

1 *$ 1 * )* * (( 8

( * $

' 1* A 1 1 ' 1* A 1 1

. * 8 - * *$

$ C$ * D

. * . * *$ -

C D

* 3

C * D

(4)

EclipseUML by examples 13

)* $9 . 1 -, )* $9 . 1 -,

* $ * - -$

Board Game Rule

!

EclipseUML by examples 14

9 9

+ 9

public Board() {

this.cells = new int[10][10];

}

public Board(int[][] cells) { this.cells = cells;

}

public String toString() {

return "Board for game of life";

}

A A 9 9 ' ' 9 9

+ A 9

public Game(Board aBoard) { this.board = aBoard;

this.generation = 1;

}

public Game() {

setBoard( new Board());

}

+ ' 9

public Rule(String name) { this .name = name;

}

($ <(

($ <(

( . * ($ < * 1 . /

int[][] boardCells = {

{0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}};

Board board = new Board(boardCells);

Game game = new Game(board);

game

(5)

EclipseUML by examples 17

( (

7 . - 1* A . .

* (( ,

6

: 1 ( 1 * *

A

- /

public static Game getIstance() { if(theInstance == null)

theInstance = new Game();

return theInstance;

}

EclipseUML by examples 18

+ +

+ * /

public String toString(){

StringBuffer buffer = new StringBuffer();

for (int i = 0; i < getCells().length; i++){

buffer.append("\n");

for (int j = 0; j < getCells()[0].length; j++){

if (getCells()[i][j] == 0) buffer.append(”0");

else

buffer.append(”1");

} }

return buffer.toString();

}

($ <(

($ <(

+8 . * ($ < * 1 . /

int[][] boardCells = {

{0, 0, 0, 1, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 1, 0, 0, 0 , 0, 0, 1}, {0, 0, 1, 1, 1, 0, 0 , 0, 0, 1}, {0, 0, 1, 1, 1, 0, 0 , 0, 0, 1}, {0, 0, 1, 1, 1, 0, 0 , 0, 0, 1}, {0, 0, 0, 1, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0 , 0, 0, 1}, {0, 0, 0, 1, 0, 0, 0 , 0, 0, 1}, {0, 0, 1, 1, 1, 0, 0 , 0, 0, 1}, {0, 0, 1, 1, 1, 0, 0 , 0, 0, 1}};

Board board = new Board(boardCells);

System.out.println(board)

' 1 ' 1

* * Board TwoDimensionalBoard

' 1 "E'

$ Board . *

$ evolve *

public abstract void evolve(Game);

public abstract void

evolve(Game, int);

(6)

EclipseUML by examples 21

' ' ' 1 ' 1

* * Rule 1 abstract

* 1 . /

EclipseUML by examples 22

1 1

. 1 TwoDimensionalRule . * . * / ((-CD

F CD

* (- 3

1 $ * . $ 43

1 * . $

1 1 ( (

( * !

(

(7)

EclipseUML by examples 25

' * A

' * A

< * Game ( - 1 abstract

TwoDimensionalGame * * 1 Game

: 1 * Game * /

public Game() {

this.rules = new Rule[3];

this.generation = 1;

}

( TwoDimensionalGame

* 1 . $ * 1* /

private TwoDimensionalGame(){

setBoard(new TwoDimensionalBoard());

getRules()[0] = new TwoDimensionalBirthRule("Birth Rule");

getRules()[1] = new TwoDimensionalSurvivalRule("Survivel Rule");

getRules()[2] = new TwoDimensionalDeathRule("Death Rule");

}

EclipseUML by examples 26

* *

* *

( evolve * * TwoDimensionalBoard

public void evolve(Game aGame) { boolean doesAnyApply = false;

TwoDimensionalRule rule = null;

for (int i = 0; i < cells.length; i++){

for (int j = 0; j < cells[0].length; j++){

doesAnyApply = false;

for (int k = 0; k < aGame.getRules().length; k++){

rule = (TwoDimensionalRule)aGame.getRules()[k];

if(rule.doesApply(getCells(), i, j)){

getCells()[i][j] = rule.getCellValue();

doesAnyApply = true;

break;

} }

if (!(doesAnyApply))

System.out.println("No rules apply for cell[" + i + "][" + j + "]");

} } }

+ *

+ *

( evolve * .* * $

- ( index/

public void evolve(Game aGame, int index){

if (index == 0) return;

for (int i = 1; i <= index; i++){

evolve(aGame);

System.out.println(this);

} }

( * * Game /

public void run(){

getBoard().evolve( this , getGeneration());

}

* *

. ( < . . * * <

* 1 . /

public static void main(String[] args) { int[][] boardCells = {

{0, 0, 0, 1, 0, 0, 1 , 0, 1, 0}, {0, 0, 1, 0, 1, 0, 1 , 0, 0, 0}, {1, 0, 0, 1, 0, 0, 1 , 0, 0, 0}, {0, 0, 0, 1, 0, 0, 1 , 0, 0, 0}, {0, 0, 1, 0, 1, 0, 1 , 1 ,0, 0}, {0, 0, 0, 1, 0, 0, 1 , 1, 1, 0}, {0, 0, 0, 1, 0, 0, 1 , 1, 0, 1}, {1, 0, 1, 0, 1, 0, 1 , 0, 1, 0}, {0, 0, 1, 0, 1, 0, 1 , 0, 1, 1}, {0, 0, 0, 1, 0, 0, 1 , 0, 0, 1}};

TwoDimensionalBoard board = new TwoDimensionalBoard(boardCells);

TwoDimensionalGame game = TwoDimensionalGame.getInstance();

game.setBoard(board);

game.setGeneration(10);

game.run();

}

Riferimenti

Documenti correlati

In conclusione, le soluzioni degli istituti bancari per risolvere i problemi e potenziare la crescita dell'impresa sono: la ricerca delle affinità elettive tramite la

Data sources for page 2: Feeling citizens of the EU data are extrapolated from Standard Eurobarometer 73 (2010) and Standard Eurobarometer 90 (2018), Satisfaction of the

The damping g and the modified eigenvalues ω of the system are calculated for discrete values of reduced frequencies (0.1, 0.2, 0.3, 0.6, 0.9, 1.2, 1.5) using the common K-E method.

Create an abstract class Board with abstract evolve methods. public abstract void

In particular, benzene is monitored as competition efficiency between the 1- aminoanthracene (fluorescent probe) and benzene for the pOBP binding site.. The

With the aim of investigating whether the presence of the host affected the phenotypic evolution of Lp, and specifically of its growth promoting effect, single strains isolated at

Likewise, if your accomplice confesses while you remain silent, he will go free (freedom) while you do the time (4 years in jail). • If you both confess I get two convictions, but

public abstract class Wind extends Instrument { abstract public void play(Note n);. public String what() { return &#34;Wind&#34;; } public void