Ajouter un commentaire

Niroken

Hello,

Bon même si ce n'est pas l'endroit pour poser ce genre de chose,
je vais te répondre, avec le peu que j'ai compris, et comme je ne
sais pas quel langage tu as utilisé, je te propose une solution en java.

import java.util.Map;

public class Note {
	
	private Map<Integer, NoteElement> mNotesElements;
	private NoteStatus mNoteStatus;
	
	public Note(Map<Integer, NoteElement> pNotesElements) {
		mNotesElements = pNotesElements;
		mNoteStatus = NoteStatus.added;
	}
	
	public void deleteNote(int pDeltaEntrePos0et1) {
		if (mNotesElements.get(new Integer(0)).getValue() - mNotesElements.get(new Integer(1)).getValue() == pDeltaEntrePos0et1) {
			mNoteStatus = NoteStatus.deleted;
		}
	}

	public Map<Integer, NoteElement> getNotesElements() {
		return mNotesElements;
	}

	public void setNotesElements(Map<Integer, NoteElement> notesElements) {
		mNotesElements = notesElements;
	}

	public NoteStatus getNoteStatus() {
		return mNoteStatus;
	}

	public void setNoteStatus(NoteStatus noteStatus) {
		mNoteStatus = noteStatus;
	}
	
	public String toString() {
		return ("" + mNotesElements.get(new Integer(1)).getValue() + mNotesElements.get(new Integer(0)).getValue());
	}
	
}

enum NoteStatus {
	deleted, added
}


public class NoteElement {
	
	private int mPosition;
	private int mValue;
	
	public NoteElement(int pPosition, int pValue) {
		mPosition = pPosition;
		mValue = pValue;
	}

	public int getPosition() {
		return mPosition;
	}

	public void setPosition(int position) {
		mPosition = position;
	}

	public int getValue() {
		return mValue;
	}

	public void setValue(int value) {
		mValue = value;
	}
	
}

Et la classe main qui sert d'exemple :

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class Program {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List<Note> vNotes = new ArrayList<Note>();
		//Note 00
		HashMap<Integer, NoteElement> vNotesElements0 = new HashMap<Integer, NoteElement>();
		vNotesElements0.put(new Integer(0), new NoteElement(0, 0));
		vNotesElements0.put(new Integer(1), new NoteElement(1, 0));
		vNotes.add(new Note(vNotesElements0));
		
		//Note 01
		HashMap<Integer, NoteElement> vNotesElements1 = new HashMap<Integer, NoteElement>();
		vNotesElements1.put(new Integer(0), new NoteElement(0, 1));
		vNotesElements1.put(new Integer(1), new NoteElement(1, 0));
		vNotes.add(new Note(vNotesElements1));
		
		//Note 02
		HashMap<Integer, NoteElement> vNotesElements2 = new HashMap<Integer, NoteElement>();
		vNotesElements2.put(new Integer(0), new NoteElement(0, 2));
		vNotesElements2.put(new Integer(1), new NoteElement(1, 0));
		vNotes.add(new Note(vNotesElements2));
		
		//Note 03
		HashMap<Integer, NoteElement> vNotesElements3 = new HashMap<Integer, NoteElement>();
		vNotesElements3.put(new Integer(0), new NoteElement(0, 3));
		vNotesElements3.put(new Integer(1), new NoteElement(1, 0));
		vNotes.add(new Note(vNotesElements3));
		
		//Note 04
		HashMap<Integer, NoteElement> vNotesElements4 = new HashMap<Integer, NoteElement>();
		vNotesElements4.put(new Integer(0), new NoteElement(0, 4));
		vNotesElements4.put(new Integer(1), new NoteElement(1, 0));
		vNotes.add(new Note(vNotesElements4));
		
		//Affichage des notes
		for (Note vNoteTmp : vNotes) {
			if (vNoteTmp.getNoteStatus() == NoteStatus.added) {
				System.out.println(vNoteTmp);
			}
		}
		
		System.out.println("--");
		
		//Suppression des notes dont la différence entre le chiffre des unitées et celui des dizaines vaut 3
		for (Note vNoteTmp : vNotes) {
			vNoteTmp.deleteNote(3);
		}
		
		//Affichage des notes après suppression
		for (Note vNoteTmp : vNotes) {
			if (vNoteTmp.getNoteStatus() == NoteStatus.added) {
				System.out.println(vNoteTmp);
			}
		}
	}

}

Sinon pour explication je suis parti du principe que une "Note" était une liste de "NoteElement".
Un "NoteElement" contient une valeur et une position.
Pour les positions : Zero est la position du chiffre le plus a droite donc le chiffre des unités, 1 celui des dizaines, 2 des centaines etc...tu n'es donc pas limité a des notes à deux chiffres.
Pour les valeurs : un chiffre compris entre 0 et 9, ici je n'ai pas fait de vérification, je te laisserais ca :)

Bonne chance,
Niroken

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 BBBB    SSS   K  K  Y   Y  EEEE 
B B S K K Y Y E
BBBB SSS KK Y EEE
B B S K K Y E
BBBB SSSS K K Y EEEE