Advertisement
amalmqui

Untitled

Apr 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // IDScore.cpp
  2. // Sander Malmquist
  3. // COSC 1030 Spring 2016
  4. // Program 13
  5. // April 29, 2016
  6.  
  7. #include "IDScore.h"
  8.  
  9. IDScore::IDScore(const char *in_name, int in_score, int ID) :
  10. studentName(in_name), studentScore(0), stuID(0)
  11. {
  12. if (in_score > 0) {
  13. studentScore = in_score;
  14. }
  15. else {
  16. throw TestError("Negative grade");
  17. }
  18. if (ID > 0)
  19. {
  20. stuID = ID;
  21. }
  22. else
  23. {
  24. throw ScoreError("Student ID less than one");
  25. }
  26. }
  27.  
  28. IDScore::IDScore(string in_name, int in_score, int ID) :
  29. studentName(in_name), studentScore(0), stuID(0)
  30. {
  31. if (in_score > 0) {
  32. studentScore = in_score;
  33. }
  34. else {
  35. throw TestError("Negative grade");
  36. }
  37. if (ID > 0)
  38. {
  39. stuID = ID;
  40. }
  41. else
  42. {
  43. throw ScoreError("Student ID less than one");
  44. }
  45. }
  46.  
  47. int IDScore::getID(void)
  48. {
  49. return stuID;
  50. }
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. // IDScore.h
  59. // Sander Malmquist
  60. // COSC 1030 Spring 2016
  61. // Program 13
  62. // April 29, 2016
  63.  
  64. #ifndef IDSCORE_H
  65. #define IDSCORE_H
  66.  
  67. #include"TestScore.h"
  68.  
  69. class ScoreError : public runtime_error
  70. {
  71. public:
  72. ScoreError(const string& msg) :runtime_error(msg) {}
  73. };
  74.  
  75. class IDScore : public TestScore
  76. {
  77. public:
  78. IDScore(const char *in_name, int in_score, int ID);
  79. IDScore(string in_name, int in_score, int ID);
  80. int getID(void);
  81.  
  82. private:
  83. string studentName;
  84. int studentScore;
  85. int stuID;
  86. };
  87.  
  88. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement