Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can some one write a method for this class in java (fill it where it says YOUR CODE HERE), I have also attached instructions :
Can some one write a method for this class in java (fill it where it says "YOUR CODE HERE"), I have also attached instructions :
import java.util.Arrays; public class MakeFractal { private final static int NOT_FOUND=-1; private String alphaNumeric; private String computedFractal; // the initial string is the axion private String initialAxion; // the initial string is the axion private Integer index,numSymbols,n,size; private String[] symbols; private String[] rules; private Integer charsPerLine=60; // constructor public MakeFractal(String[] symbols,Integer numSymbols, String initialAxion,String[] rules,Integer n) { this.numSymbols=numSymbols; this.symbols=new String[this.numSymbols]; this.rules=new String[this.numSymbols]; for(int i=0;is = new LinkedStack (); ************************ **** YOUR CODE HERE **** ************************ return computedFractal; } // Return the index of the character in symbols // or -1 if it is not there public Integer in(String alphaNumeric,String[] symbols) { for(int i=0;i buildFractal method: you have to write this: n-0 the computedFractal string is the axion for iter = 1:n for i-0:length of computedFratcal process each i'th character of computedFractal as follows: q-computedFractal.substring(i,i+1) is q a symbol: F, G, X, Y, +,-,[,]? You can use integer method in to determine this. If method in returns NOT_FOUND -1) push (q) if method in retuns an integer >= 0 This is the symbol index in the symbols array. Use the symbol index to get the production rule (rules (index)) and push (rules (index)) rather than q Set comutedFractal to "", the empty string Until the stack is empty, pop the stack concatenate each popped item to the left of the string computedFractal This is the new value of computedFractal after this iteration return computedFractal; method in does as just explained above method prettPrint prints the string computedFractal 60 characters per line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started