Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object Oriented:
- public class Tree
- {
- private int m_leafCount;
- private string m_season;
- private float m_nutrientLevel;
- public Tree(TreeType p_type)
- {
- TreeDataBase l_database = TreeDataBase.GetInstance();
- Initialize(l_database.GetValues(p_type));
- }
- }
- void main()
- {
- Tree l_appleTree = new Tree(TreeType.Apple);
- Tree l_orangeTree = new Tree(TreeType.Orange);
- }
- ***
- Procedural:
- void main()
- {
- FileHandler l_database = new FileHandler("treeDatabase.db");
- // tree1
- int l_leafCount1;
- string l_season1;
- float l_nutrientLevel1;
- // tree2
- int l_leafCount2;
- string l_season2;
- float l_nutrientLevel2;
- while (!l_database.eof())
- {
- string l_currentLine = l_databse.getLine();
- if (indexOf(l_currentLine, "apple") > 0)
- {
- string[] l_splitLine = splitString(l_currentLine, ",");
- l_leafCount1 = atoi(l_splitLine[0]);
- l_season1 = l_splitLine[1];
- l_nutrientLevel = atof(l_splitLine[2]);
- }
- else if (indexOf(l_currentLine, "orange") > 0)
- {
- string[] l_splitLine = splitString(l_currentLine, ",");
- l_leafCount2 = atoi(l_splitLine[0]);
- l_season2 = l_splitLine[1];
- l_nutrientLeve2 = atof(l_splitLine[2]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement