Guest User

Untitled

a guest
Oct 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. Class CircleDividerParser{
  2.  
  3. // does the parsing logic to capture the values
  4. void Dowork(filename){
  5. std::ifstream file_stream.open(filename);
  6. std::string line;
  7. while(std::getline(file_stream, line){
  8. std::string str;
  9. std::stringstream ss(line);
  10. int i = 0;
  11. while(std::getline(ss, str, ',')){
  12. holder[i] = str;
  13. i++;
  14. }
  15. pcc.add_pie_cutting_info(holder);
  16. }
  17.  
  18. }
  19.  
  20. private:
  21. std::array<std::string, 9> holder;
  22. PieCutterCreator pcc;
  23.  
  24. };
  25.  
  26. class PieCutterCreator{
  27.  
  28. public:
  29. void add_pie_cutting_info(std::array<std::string, 9> arr){
  30. PieCuttingInfo obj;
  31.  
  32. obj.AddPieCuttingStyleName(arr[0]);
  33. obj.AddRadius(arr[1]);
  34. ...
  35. ..
  36.  
  37. }
  38. PieCuttingInfo GetPieCuttingInfo(const std::string& name_to_find);
  39.  
  40. std::vector<PieCuttingInfo> GetAllPieCuttingInfo() { return collect;}
  41.  
  42. private:
  43. std::vector<PieCuttingInfo> collect;
  44.  
  45. };
  46.  
  47. class PieCuttingInfo{
  48.  
  49. class enum angle_type {Degree, Radian};
  50.  
  51. public:
  52. PieCuttingInfo()=default;
  53.  
  54. void AddPieCuttingStyleName(const std::string& name){ pie_cutting_style_name = name;}
  55.  
  56. void AddRaius(const std::string& r) {radius = r;}
  57.  
  58. void AddAngleType(const std::string& at) {
  59. if(at == "degree"){
  60. angle_value = angle_type::Degree;
  61. }else if(at == "radian"){
  62. angle_value = angle_type::Radian;
  63. }else {// error}
  64. }
  65. ...
  66.  
  67.  
  68. private:
  69.  
  70. std::string pie_cutting_style_name;
  71. std::string radius;// radius or pie
  72. std::string x;// x-coordinate of pie center
  73. std::string y;// y-coordinate of pie center
  74. std::string angle_type; angle can be either degree or radian
  75. std::string angle_value; value of angle that could be radian or degree
  76. std::string direction; clock wise or anti-clockwise angle
  77. std::string from_x; x point in circle from where the angle is measured
  78. std::string from_y; y point in circle from where the angle is measured
  79.  
  80. };
  81.  
  82.  
  83. class PieCuttingMaching(){
  84.  
  85. void DoAllThePieCutting(){
  86. save = obj.GetAllPieCuttingInfo();
  87. for(auto& it: save){
  88. // use the info from PieCuttingInfo to do the job
  89. }
  90. }
  91.  
  92. private:
  93. std::vector<PieCuttingInfo> save;
  94. PieCutterCreator obj;
  95. }
Add Comment
Please, Sign In to add comment