Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class CircleDividerParser{
- // does the parsing logic to capture the values
- void Dowork(filename){
- std::ifstream file_stream.open(filename);
- std::string line;
- while(std::getline(file_stream, line){
- std::string str;
- std::stringstream ss(line);
- int i = 0;
- while(std::getline(ss, str, ',')){
- holder[i] = str;
- i++;
- }
- pcc.add_pie_cutting_info(holder);
- }
- }
- private:
- std::array<std::string, 9> holder;
- PieCutterCreator pcc;
- };
- class PieCutterCreator{
- public:
- void add_pie_cutting_info(std::array<std::string, 9> arr){
- PieCuttingInfo obj;
- obj.AddPieCuttingStyleName(arr[0]);
- obj.AddRadius(arr[1]);
- ...
- ..
- }
- PieCuttingInfo GetPieCuttingInfo(const std::string& name_to_find);
- std::vector<PieCuttingInfo> GetAllPieCuttingInfo() { return collect;}
- private:
- std::vector<PieCuttingInfo> collect;
- };
- class PieCuttingInfo{
- class enum angle_type {Degree, Radian};
- public:
- PieCuttingInfo()=default;
- void AddPieCuttingStyleName(const std::string& name){ pie_cutting_style_name = name;}
- void AddRaius(const std::string& r) {radius = r;}
- void AddAngleType(const std::string& at) {
- if(at == "degree"){
- angle_value = angle_type::Degree;
- }else if(at == "radian"){
- angle_value = angle_type::Radian;
- }else {// error}
- }
- ...
- private:
- std::string pie_cutting_style_name;
- std::string radius;// radius or pie
- std::string x;// x-coordinate of pie center
- std::string y;// y-coordinate of pie center
- std::string angle_type; angle can be either degree or radian
- std::string angle_value; value of angle that could be radian or degree
- std::string direction; clock wise or anti-clockwise angle
- std::string from_x; x point in circle from where the angle is measured
- std::string from_y; y point in circle from where the angle is measured
- };
- class PieCuttingMaching(){
- void DoAllThePieCutting(){
- save = obj.GetAllPieCuttingInfo();
- for(auto& it: save){
- // use the info from PieCuttingInfo to do the job
- }
- }
- private:
- std::vector<PieCuttingInfo> save;
- PieCutterCreator obj;
- }
Add Comment
Please, Sign In to add comment