fork download
  1. #include <stdio.h>
  2.  
  3. /************************************************************
  4.  * Question 8 – Horse Racing Program Structures (C ONLY)
  5.  ************************************************************/
  6.  
  7. /* ------------------ Macros ------------------ */
  8.  
  9. #define MAX_NAME_LEN 50
  10. #define MAX_JOCKEY_LEN 50
  11. #define MAX_TRAINER_LEN 50
  12. #define MAX_TRACK_LEN 50
  13. #define MAX_HORSES 20
  14.  
  15. /* ------------------ Enumerations ------------------ */
  16.  
  17. typedef enum
  18. {
  19. MALE,
  20. FEMALE,
  21. GELDING
  22. } HorseGender;
  23.  
  24. typedef enum
  25. {
  26. FAST,
  27. GOOD,
  28. MUDDY,
  29. SLOPPY
  30. } TrackCondition;
  31.  
  32. /* ------------------ Supporting Structures ------------------ */
  33.  
  34. typedef struct
  35. {
  36. int month;
  37. int day;
  38. int year;
  39. } date;
  40.  
  41. typedef struct
  42. {
  43. int wins;
  44. int places;
  45. int shows;
  46. int totalStarts;
  47. } performance_stats;
  48.  
  49. typedef struct
  50. {
  51. char jockeyName[MAX_JOCKEY_LEN];
  52. char trainerName[MAX_TRAINER_LEN];
  53. } connections;
  54.  
  55. typedef struct
  56. {
  57. float odds;
  58. int postPosition;
  59. } betting_info;
  60.  
  61. /* ------------------ Horse Details & Past Performance ------------------ */
  62.  
  63. typedef struct
  64. {
  65. int programNumber; // 1
  66. char horseName[MAX_NAME_LEN]; // 8
  67. HorseGender gender; // 10
  68. int age;
  69. int weightCarried;
  70. performance_stats pastPerformance;
  71. connections team;
  72. betting_info betting;
  73. } horse_details_and_past_performance;
  74.  
  75. /* ------------------ Race Details ------------------ */
  76.  
  77. typedef struct
  78. {
  79. date raceDate; // A
  80. int raceNumber; // C
  81. char trackName[MAX_TRACK_LEN]; // E
  82. float distance; // furlongs or miles
  83. TrackCondition condition;
  84. int purseAmount;
  85. int numberOfHorses;
  86. horse_details_and_past_performance horses[MAX_HORSES];
  87. } race_details;
  88.  
  89. /* ------------------ Example Main (compile test only) ------------------ */
  90.  
  91. int main(void)
  92. {
  93. race_details myRaces[10];
  94.  
  95. /* No initialization required per instructions */
  96.  
  97. return 0;
  98. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty