Seems to work
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user