Creat a working implementation of the MixedFlatteningList interface. Submit thre
ID: 668756 • Letter: C
Question
Creat a working implementation of the MixedFlatteningList interface.
Submit three .java files: The interface, your implementation, and any test code that you wrote.
Submit a short description of your process and the results in a .txt file.
public interface MixedFlatteningList {
public MixedFlatteningList get(int index);
public boolean isInt();
public boolean isString();
public boolean isCompound();
public int getInt();
public String getString();
public void clear();
public void add(int value);
public void add(String value);
public void add(MixedFlatteningList value);
public void set(int value, int index);
public void set(String value, int index);
public void set(MixedFlatteningList value, int index);
public String toString();
public void flatten();
public MixedFlatteningList toFlattened();
public boolean isFlat();
public MixedFlatteningList clone();
}
Explanation / Answer
Hi,
I tried my best I have Added three java files,one is implementation class,one is interface and the third one is
test class to test our two classes....
Client Class:
public class Client {
public static void main(String[] args) {
MixedFlatteningListImplementation mil=new MixedFlatteningListImplementation();
mil.add(0);
mil.add(10);
mil.add("22");
mil.clear();
mil.flatten();
mil.isString("jiji");
mil.isInt(0);
}
}
Implementation:
public class MixedFlatteningListImplementation {
public int get(int index){
int setindex=index;
return setindex;
}
public boolean isInt(int index){
//this method determines whether the given number is int or not...
// logic to check isint is
int x=get(0);
if (x == (int)index){
return true;
}else{
return false;
}
}
public boolean isString(String str){
return false;
//this method checks for t given number is
}
public boolean isCompound(int integer){
return false;
}
public void clear(){
}
public void add(int value){
}
public void add(String value){
}
public void add(MixedFlatteningList value){
}
public void set(int value){
}
public void set(String value){
}
public void set(MixedFlatteningList value){
}
public String toString(String str){
return null;
}
public void flatten(){
}
public void toFlattened(){
}
public void isFlat(){
}
public MixedFlatteningList clone(MixedFlatteningList value){
MixedFlatteningList copy=value.clone(value);
return copy;
}
}
Interface:
public interface MixedFlatteningList {
public MixedFlatteningList get(int index);
public boolean isInt();
public boolean isString();
public boolean isCompound();
public int getInt(String index);
//this method gets the integer for the given string...
public String getString(int index);
//this method gets the sting ..
public void clear();
//this method clears the list.
public void add(int value);
//this method adds the integer values to list..
public void add(String value);
//this method adds the string to list
public void add(MixedFlatteningList value);
//this method adds the two integer values..
public void set(int value);
//this method sets the integer values..
public void set(String value);
//this method sets the String values..
public void set(MixedFlatteningList value);
//this method sets MixedFlatteningList values..
public String toString();
//this method gets the toString value..
public void flatten();
//this method makes stream for object..
public MixedFlatteningList toFlattened();
public boolean isFlat();
public MixedFlatteningList clone(MixedFlatteningList lol);
}