36 lines
627 B
C#
36 lines
627 B
C#
using System;
|
|
|
|
namespace EinmaleinsTrainer.Models;
|
|
|
|
public class Question : IEquatable<Question>
|
|
{
|
|
public int A { get; set; }
|
|
public int B { get; set; }
|
|
|
|
public int CorrectAnswer => A * B;
|
|
|
|
public bool Equals(Question? other)
|
|
{
|
|
if (other is null) return false;
|
|
|
|
return A == other.A &&
|
|
B == other.B;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return Equals(obj as Question);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(A, B);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{A} x {B}";
|
|
}
|
|
}
|
|
|