how would you create these in java

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

how would you create these in java

state s;
int x = 0;
if ( 0 == x)
else s =
Cell
-s: state
-alive :char
-dead : char
Lets start with the Cell class. Here is the the UML class diagram for it :
s = state. DEAD; //access values via type name
state.ALIVE;
+Cell(s:state)
+Cell(s:state, alive :char, dead :char)
+getState(): state
+setState(s:state) : void
+Draw(): void
Next we have the abstract class Board
Board
#curr : Cell[][]
#alive :char
#dead : char
// you can create a variable
// of the enumurated type
+setCell(i :int, j: int, c : Cell) : void
+getCell(i :int, j: int) :Cell
+Draw(): void
+numLiveCell((i :int, j : int) : int
+nextGen():void
The state of the cell
Character to draw on screen if cell is alive (default='#')
Character to draw on screen if cell is dead (default='')
Constructs a cell with the given state and default chars
Constructs a cell with the given state and characters
Returns state of cell
Sets state of cell.
Draw method implementation of Drawable interface
+Board(r:int; c:int)
Creates array curr with r rows and c columns
+Board(r:int, c:int, alive :char, dead :char) Like above but also changes printing characters
+setBoard (s:state) : void
Creates and sets the state of ALL cells in curr to s.
A 2-D array used to represent the board (or row)
Character to draw on screen if cell is alive (default='#')
Character to draw on screen if cell is dead (default='')
Changes reference at curr[i][j] to c
Returns reference to cell found at curr[i][j]
Draw method implementation of Drawable interface
How many live cells exist around cell at curr[i][j]
Computes new generation based on old
Transcribed Image Text:state s; int x = 0; if ( 0 == x) else s = Cell -s: state -alive :char -dead : char Lets start with the Cell class. Here is the the UML class diagram for it : s = state. DEAD; //access values via type name state.ALIVE; +Cell(s:state) +Cell(s:state, alive :char, dead :char) +getState(): state +setState(s:state) : void +Draw(): void Next we have the abstract class Board Board #curr : Cell[][] #alive :char #dead : char // you can create a variable // of the enumurated type +setCell(i :int, j: int, c : Cell) : void +getCell(i :int, j: int) :Cell +Draw(): void +numLiveCell((i :int, j : int) : int +nextGen():void The state of the cell Character to draw on screen if cell is alive (default='#') Character to draw on screen if cell is dead (default='') Constructs a cell with the given state and default chars Constructs a cell with the given state and characters Returns state of cell Sets state of cell. Draw method implementation of Drawable interface +Board(r:int; c:int) Creates array curr with r rows and c columns +Board(r:int, c:int, alive :char, dead :char) Like above but also changes printing characters +setBoard (s:state) : void Creates and sets the state of ALL cells in curr to s. A 2-D array used to represent the board (or row) Character to draw on screen if cell is alive (default='#') Character to draw on screen if cell is dead (default='') Changes reference at curr[i][j] to c Returns reference to cell found at curr[i][j] Draw method implementation of Drawable interface How many live cells exist around cell at curr[i][j] Computes new generation based on old
Queue q = new Queue (3);
System.out.println (q.capacity());
double a[] = {1,2,-3, 4, 5, 6, 1, 2);
for ( double i : a) {
q.push_back (i);
}
System.out.println (q.capacity () );
while (!q.empty()) {
}
System.out.print (q. front () + " ");
q.pop_front ();
System.out.println (q.capacity () );
System.out.println();
Deque dq = new Deque (3);
System.out.println (q.capacity());
boolean flip = true;
for (double i : a) {
if (flip) {
}
}
}
}
flip = !flip;
System.out.println (dq.capacity () );
while (!dq.empty()) {
dq.push_back (i);
else {
dq.push_front (i);
System.out.print (dq. front () + " ");
dq.pop_front ();
System.out.print (dq.back () + " ");
dq.pop_back ();
System.out.println();
System.out.println (dq.capacity());
This is what your output should look like :
0
8
1.0 2.0 -3.0 4.0 5.0 6.0 1.0 2.0
0
0
8
2.0 1.0 6.0 5.0 4.0 -3.0 2.0 1.0
0
Transcribed Image Text:Queue q = new Queue (3); System.out.println (q.capacity()); double a[] = {1,2,-3, 4, 5, 6, 1, 2); for ( double i : a) { q.push_back (i); } System.out.println (q.capacity () ); while (!q.empty()) { } System.out.print (q. front () + " "); q.pop_front (); System.out.println (q.capacity () ); System.out.println(); Deque dq = new Deque (3); System.out.println (q.capacity()); boolean flip = true; for (double i : a) { if (flip) { } } } } flip = !flip; System.out.println (dq.capacity () ); while (!dq.empty()) { dq.push_back (i); else { dq.push_front (i); System.out.print (dq. front () + " "); dq.pop_front (); System.out.print (dq.back () + " "); dq.pop_back (); System.out.println(); System.out.println (dq.capacity()); This is what your output should look like : 0 8 1.0 2.0 -3.0 4.0 5.0 6.0 1.0 2.0 0 0 8 2.0 1.0 6.0 5.0 4.0 -3.0 2.0 1.0 0
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education