Seems to work

This commit is contained in:
2017-01-26 19:32:16 +02:00
parent 077fda732a
commit f2bb4b3e5c
10 changed files with 184 additions and 34 deletions

View File

@@ -3,11 +3,30 @@ using System.Collections;
namespace Päevaküsimus.Models
{
public class Answer
[Serializable()]
public class Answer : NotificationBase, ICloneable
{
public string answer { get; set; }
private string _answer;
public string answer {
get { return _answer; }
set
{
_answer = value;
NotifyPropertyChanged();
}
}
public bool correct { get; set; }
public int selectionCount { get; set; }
private int _selectionCount;
public int selectionCount
{
get { return _selectionCount; }
set
{
_selectionCount = value;
NotifyPropertyChanged();
}
}
public Answer(string answer)
{
@@ -20,5 +39,12 @@ namespace Päevaküsimus.Models
this.answer = answer;
this.correct = correct;
}
public object Clone()
{
var c = new Answer(answer.Clone() as string, correct);
c.selectionCount = selectionCount;
return c;
}
}
}

View File

@@ -4,10 +4,20 @@ using System.Collections.ObjectModel;
namespace Päevaküsimus.Models
{
public class Question
[Serializable()]
public class Question : NotificationBase, ICloneable
{
public string question { get; set; }
private string _question;
public string question {
get { return _question; }
set
{
_question = value;
NotifyPropertyChanged();
}
}
private ObservableCollection<Answer> _answers;
public ObservableCollection<Answer> answers { get { return _answers; } }
public Question(string question)
{
@@ -15,11 +25,19 @@ namespace Päevaküsimus.Models
this._answers = new ObservableCollection<Answer>();
}
public ObservableCollection<Answer> answers { get { return _answers; } }
public void AddAnswer(Answer answer)
{
_answers.Add(answer);
}
public object Clone()
{
var q = new Question(_question.Clone() as string);
foreach (var answer in _answers)
{
q.AddAnswer(answer.Clone() as Answer);
}
return q;
}
}
}