-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNote.cs
50 lines (44 loc) · 1.54 KB
/
Note.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Text;
namespace ABC
{
public class Note : Duration, IComparable<Note>
{
public Pitch pitch { get; set; }
public Accidental accidental { get; set; }
public Note(Pitch pitch = Pitch.C4, Length length = Length.Eighth, Accidental accidental = Accidental.Unspecified, int dotCount = 0)
: base(Item.Type.Note)
{
this.pitch = pitch;
this.length = length;
this.accidental = accidental;
this.dotCount = dotCount;
}
public override bool Equals(object obj)
{
return obj is Note note &&
pitch == note.pitch &&
accidental == note.accidental &&
length == note.length &&
dotCount == note.dotCount;
}
public override int GetHashCode()
{
var hashCode = 838805952;
hashCode = hashCode * -1521134295 + pitch.GetHashCode();
hashCode = hashCode * -1521134295 + accidental.GetHashCode();
hashCode = hashCode * -1521134295 + length.GetHashCode();
hashCode = hashCode * -1521134295 + dotCount.GetHashCode();
return hashCode;
}
public override string ToString()
{
return $"{pitch.ToString()}, {accidental.ToString()}, {length.ToString()}";
}
public int CompareTo(Note other)
{
return pitch.CompareTo(other.pitch);
}
}
}