mercredi 1 mai 2019

how to implement a component in java

so i am a bit not good at programming. i want to implement a memory stack.

i have already written some methods and i need help or guides for the implementations. i will give the classes below

/** * This MemoryStackService is an interface to help memorize information * through stacks of index cards. */

public interface MemoryStackService {

/**
 * Returns a list of available index card stacks.
 *
 * @return List of index card stacks
 */
List<MemoryStackDescriptor> getMemoryStacks();

/**
 * Returns the descriptor of the memory stack with the given id.
 *
 * @param id id of the memory stack
 * @return descriptor of the memory stack
 * @throws IllegalParameterException if the id does not exist
 */
MemoryStackDescriptor getMemoryStack(int id) throws IllegalParameterException;


List<IndexCard> getCards(int stackId, boolean randomized) throws IllegalParameterException;

/**
 * stages index cards which were not answered correctly to be asked again.
 *
 * @param id
 * @throws IllegalParameterException if the id does not exist
 */
void addWrongAnsweredCards(int id) throws IllegalParameterException;

void addCorrectAnsweredCards(int id) throws IllegalParameterException;

List<IndexCard> getWrongAnsweredCards();

void resetWrondAnsweredCards();

int createMemoryStack(String name) throws IllegalParameterException;

int addCard(int stackId, IndexCard card) throws IllegalParameterException;

}

public class IndexCard {

private int id;
private String content;
private String solution;
private boolean knewAnswer;

public int getCardId()
{
    return id;
}

public String getCardContent() {

    return content;
}

public String getSolution() {

    return solution;
}

public void SetKnewAnswer(boolean knewAnswer) {
    this.knewAnswer = knewAnswer;
}

public boolean GetKnewAnswer() {

    return knewAnswer;
}

}

public class MemoryStackServiceMain implements MemoryStackService {

/**
 * Returns a list of available index card stacks.
 *
 * @return List of index card stacks
 */
@Override
public List<MemoryStackDescriptor> getMemoryStacks() {
    List<MemoryStackDescriptor> results = new ArrayList<>();

    return results;

}

/**
 * Returns the descriptor of the memory stack with the given id.
 *
 * @param id id of the memory stack
 * @return descriptor of the memory stack
 * @throws IllegalParameterException if the id does not exist
 */
@Override

public MemoryStackDescriptor getMemoryStack(int id) throws IllegalParameterException { return null; }

@Override
public List<IndexCard> getCards(int stackId, boolean randomized) throws IllegalParameterException
{
    return null;
}

/**
 * stages index cards which were not answered correctly to be asked again.
 *
 * @param id
 * @throws IllegalParameterException if the id does not exist
 */
@Override
public void addWrongAnsweredCards(int id) throws IllegalParameterException {}

@Override
public void addCorrectAnsweredCards(int id) throws IllegalParameterException {}

@Override
public List<IndexCard> getWrongAnsweredCards(){
    return null;
}

@Override
public void resetWrondAnsweredCards() {}

@Override
public int createMemoryStack(String name) throws IllegalParameterException {
    return 0;
}

@Override
public int addCard(int stackId, IndexCard card) throws IllegalParameterException {
    return 0;
}

}

With Memory Stack a user for example a student is able to create stacks of index cards.With those cards which contain a question and corresponding answer the student can study for an upcoming exam or learn anything else that they need to memorize.

Aucun commentaire:

Enregistrer un commentaire