# Question#1 Suppose that a list can contain items and other lists. ...

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.*;

/*
* ListBuilder main class
*/
public class ListBuilder {

// Fields to keep track of ListComponent object
ListComponent component;
int componentIndex;
// Fields to keep track of ListComposite object
ListComposite composite;
int compositeIndex;
// Level for hierarchy parsing
int level = 0;

// Method which processes an open bracket
public void buildOpenBracket() {
level++;
// Lowest level open bracket
if (level == 1) {
component = new ListComponent();
componentIndex = 0;
// Nested open bracket
} else {
composite = new ListComposite();
compositeIndex = 0;
}
}

// Method which processes an close bracket
public void buildCloseBracket() {
level--;
// Nested close bracket, add ListComposite to ListComponent
if (level == 1) {
}
}

// Method which processes an integer element
public void buildElement(int element) {
// Lowest level, add to ListComponent
if (level == 1) {
// Nested level, add to ListComposite
} else if (level == 2) {
}
}

// Get ListComponent of ListBuilder
public ListComponent getList() {
return component;
}

// Main method which runs upon execution
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
// Initially, query user for input list
String input = s.nextLine().replaceAll("\\s","");
ListBuilder builder = new ListBuilder();
// Apply ListBuilder methods to input
for (char token: input.toCharArray()) {
if (token == '[') {
builder.buildOpenBracket();
} else if (token == ']') {
builder.buildCloseBracket...

By purchasing this solution you'll be able to access the following files:
Solution.zip and Solution1.zip.

\$45.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.