Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Java Programming: Below are BooleanCompareNode.java, VariableReferenceNode.java, IfNode.java, RepeatNode.java, & WhileNode.java. Attached is an image where it's circled in blue all the methods that must be implemented in the java files that are presented below:

BooleanCompareNode.java

public class BooleanCompareNode extends Node {
enum CompareType {

eq, ne, lt, gt, le, ge

};


CompareType type;

Node left;

Node right;

public BooleanCompareNode(CompareType type, Node left, Node right) {

this.type = type;

this.left = left;

this.right = right;

}

public String ToString() {

return left.toString() + type.toString() + right.toString();

}

}

VariableReferenceNode.java

public class VariableReferenceNode extends Node{
String name;

Node arrayIndex;



public VariableReferenceNode(String name) {

this.name = name;

this.arrayIndex = arrayIndex;

}


public String ToString() {

String indexString = (arrayIndex == null) ? "" : "[" + arrayIndex.toString() + "]";

return name + indexString;

}


public void setIndex(Node indexExpr) {


}


public String getVariableName() {

return null;
}

}

IfNode.java

import java.util.ArrayList;
import java.util.List;

public class IfNode<BooleanCompare> extends Node{
private BooleanCompare condition;
private ArrayList<StatementNode> statements;
private IfNode nextIf;


public IfNode(BooleanCompare condition, ArrayList<StatementNode> statements, IfNode nextIf) {
this.condition = condition;
this.statements = statements;
this.nextIf = nextIf;
}

public BooleanCompare getCondition() {
return condition;
}

public ArrayList<StatementNode> getStatements() {
return statements;
}

public IfNode getNextIf() {
return nextIf;
}

@Override
public String ToString() {
StringBuilder sb = new StringBuilder("IfNode: { Condition: ");
sb.append(condition.toString()).append(", Statements: [");
for (StatementNode statement : statements) {
sb.append(statement.toString()).append(", ");
}
sb.delete(sb.length() - 2, sb.length());
sb.append("]");
if (nextIf != null) {
sb.append(", NextIf: ").append(nextIf.toString());
}
sb.append("}");
return sb.toString();
}
}

RepeatNode.java

import java.util.ArrayList;

public class RepeatNode<BooleanCompare> extends Node {
private BooleanCompare condition;
private ArrayList<StatementNode> statements;



public RepeatNode(BooleanCompare condition, ArrayList<StatementNode> statements) {
this.condition = condition;
this.statements = statements;
}

BooleanCompare getCondition() {
return condition;
}

public ArrayList<StatementNode> getStatements() {
return statements;
}


@Override
public String ToString() {
StringBuilder sb = new StringBuilder("RepeatNode: { Condition: ");
sb.append(condition.toString()).append(", Statements: [");
for (StatementNode statement : statements) {
sb.append(statement.toString()).append(", ");
}
sb.delete(sb.length() - 2, sb.length());
sb.append("]}");
return sb.toString();
}
}


WhileNode.java

import java.util.ArrayList;

public class WhileNode<BooleanCompare> extends Node {
private BooleanCompare condition;
private ArrayList<StatementNode> statements;


public WhileNode(BooleanCompare condition, ArrayList<StatementNode> statements) {
this.condition = condition;
this.statements = statements;
}

public BooleanCompare getCondition() {
return condition;
}

public ArrayList<StatementNode> getStatements() {
return statements;
}


@Override
public String ToString() {
StringBuilder sb = new StringBuilder("WhileNode: { Condition: ");
sb.append(condition.toString()).append(", Statements: [");
for (StatementNode statement : statements) {
sb.append(statement.toString()).append(", ");
}
sb.delete(sb.length() - 2, sb.length());
sb.append("]}");
return sb.toString();
}
}

Transcribed Image Text:booleanCompare variable ReferenceNode mathOpNode ifNode forNode repeatNode constantNodes whileNode assignmentNode Not handled (0) Not handled (0) Not handled (0) Not handled (0) Not handled(0) Not handled (0) Not handled (0) Not handled (0) Not handled(0) Calls expression(), then compares (5) Looks up nodes and returns IDT (5) Calls expression(), then calculates (5) Calls booleanCompare and chains (10) Loops over the range and calls interpretBlock(10) Calls booleanCompare and interpretBlock correctly (5) Returns a new IDT (5) Calls booleanCompare and interpretBlock correctly (5) calls expression() and replaces the IDT entry for the variable(5)
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Where are the methods being used that I circled in the rubric? I don't see anything. I added all the needed java files for the methods to be added for each java file shown above. Which is why I circled the methods. Please fix this and show me the methods being used that I circled for the java files.

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Where are the methods being used that I circled in the rubric? I don't see anything. I added all the needed java files for the methods to be added for each java file shown above. Which is why I circled the methods. Please fix this and show me the methods being used that I circled for the java files.

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
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.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education