I have already turned this in for a 0 in my class as I just dont know what to do or how to start it past what was shown in class, Which was very little. Could someone please teach me or show me where to go for my own sake to learn what im suppose to do here.
The objective is this: In this we will create a Data Structure that represents a Generic Magic Cup. In our lab we should create a generic interface for Magic items and it should be called Magic, as well as creating a generic class called Magic Cup that implements magic. All magical items should give you the ability to show whats in the item, to empty the item, place an item inside of it, or compare the magic item to another item. A magic cup should be able to hold any item of any type. We should be able to check a cup to see if it is currently empty or if it contains an item. Imagine the cup trick that is commonly done by street artist.
To test your work, in a main method you should create a methodology that implements three cups of different type, ie. ints, strings, booleans and even magic cups. Then you should be able to use the method to see if you can find the filed cup or search through all cups to see if magic happened.
so far all I have is this:
Main Method:
import java.util.*;
interface Magic<T>{
void add();
void remove();
void check();
void compare();
void show();
}
public class Main {
public static void main(String[] args) {
//int cups
Cup<Integer> cup = new Cup<Integer>(8);
Cup<Integer> cup1 = new Cup<Integer>(32);
Cup<Integer> cup2 = new Cup<Integer>(10);
//string cups
Cup<String> cup3 = new Cup<String>("Hello");
Cup<String> cup4 = new Cup<String>("Test");
Cup<String> cup5 = new Cup<String>("I am in a cup");
//boolean cups
Cup<Boolean> cup6 = new Cup<Boolean>(true);
Cup<Boolean> cup7 = new Cup<Boolean>(false);
Cup<Boolean> cup8 = new Cup<Boolean>(true);
//Magic cups
magicCup<> magicCup = new magicCup<>();
magicCup<> magicCup1 = new magicCup<>();
magicCup<> magicCup2 = new magicCup<>();
System.out.println(cup.getData());
}
}
Cup method:
public class Cup<T>{
T data;
Cup(T data){
this.data=data;
}
void setData(T data) {
this.data = data;
}
T getData() {
return data;
}
}
MagicCup Method:
public class magicCup implements Magic {
@Override
public void add(magicCup<T>) {
T data;
magicCup(T data){
this.data=data;
}
void setData(T data) {
this.data = data;
}
T getData() {
return data;
}
}
@Override
public void remove() {
}
@Override
public void check() {
// TODO Auto-generated method stub
}
@Override
public void compare() {
// TODO Auto-generated method stub
}
@Override
public void show() {
// TODO Auto-generated method stub
}
}
If someone would be willing to sit down with me for a little bit and walk me through what I would even do to start. I would greatly appreciate the help.