Word.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace TxtDictionary
  6. {
  7. public class Word
  8. {
  9. public Word(string word, List<Meaning> meanings)
  10. {
  11. this.Text = word;
  12. this.Meanings = meanings;
  13. }
  14. public string Text { get; set; }
  15. public List<Meaning> Meanings;
  16. public override string ToString()
  17. {
  18. StringBuilder sb = new StringBuilder();
  19. sb.Append(Text);
  20. foreach (var m in Meanings)
  21. {
  22. sb.Append("\t");
  23. sb.Append(m.PhoneticEN + "\t");
  24. for (int i = 0; i < m.CixingChinese.Count; i++)
  25. {
  26. if ( i > 0)
  27. {
  28. sb.Append("\t\t");
  29. }
  30. sb.Append(m.CixingChinese[i].Cixing + "\t" + m.CixingChinese[i].Chinese);
  31. sb.AppendLine();
  32. }
  33. }
  34. return sb.ToString();
  35. }
  36. }
  37. public class Meaning
  38. {
  39. public Meaning(string phoneticEN, string phoneticUS, List<CixingChinese> cc)
  40. {
  41. PhoneticEN = phoneticEN;
  42. PhoneticUS = phoneticUS;
  43. CixingChinese = cc;
  44. }
  45. public List<CixingChinese> CixingChinese;
  46. public string PhoneticEN { get; set; }
  47. public string PhoneticUS { get; set; }
  48. }
  49. public class CixingChinese
  50. {
  51. public string Cixing { get; set; }
  52. public string Chinese { get; set; }
  53. }
  54. }