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
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F66301e59-a86d-47c0-9dd8-21e24614422a%2F5420121b-3992-4e5e-819d-654c99b97fa2%2Fcc849al_processed.png&w=3840&q=75)
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F66301e59-a86d-47c0-9dd8-21e24614422a%2F5420121b-3992-4e5e-819d-654c99b97fa2%2Fwk88n8b_processed.png&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education