Changes in src/periodentafel.cpp [f66195:fb73b8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/periodentafel.cpp
rf66195 rfb73b8 21 21 * Initialises start and end of list and resets periodentafel::checkliste to false. 22 22 */ 23 periodentafel::periodentafel() 24 { 25 start = new element; 26 end = new element; 23 periodentafel::periodentafel() : start(new element), end(new element) 24 { 27 25 start->previous = NULL; 28 26 start->next = end; … … 45 43 * \return true - succeeded, false - does not occur 46 44 */ 47 bool periodentafel::AddElement(element * pointer)45 bool periodentafel::AddElement(element * const pointer) 48 46 { 49 47 pointer->sort = &pointer->Z; … … 57 55 * \return true - succeeded, false - element not found 58 56 */ 59 bool periodentafel::RemoveElement(element * pointer)57 bool periodentafel::RemoveElement(element * const pointer) 60 58 { 61 59 return remove(pointer, start, end); … … 71 69 72 70 /** Finds an element by its atomic number. 73 * If element is not yet in list, datas are asked and stored in database.71 * If element is not yet in list, returns NULL. 74 72 * \param Z atomic number 75 * \return pointer to element 76 */ 77 element * periodentafel::FindElement(int Z)73 * \return pointer to element or NULL if not found 74 */ 75 element * const periodentafel::FindElement(const int Z) const 78 76 { 79 77 element *walker = find(&Z, start,end); 80 if (walker == NULL) { // not found: enter and put into db81 cout << Verbose(0) << "Element not found in database, please enter." << endl;82 walker = new element;83 cout << Verbose(0) << "Mass: " << endl;84 cin >> walker->mass;85 walker->Z = Z;86 cout << Verbose(0) << "Atomic number: " << walker->Z << endl;87 cout << Verbose(0) << "Name [max 64 chars]: " << endl;88 cin >> walker->name;89 cout << Verbose(0) << "Short form [max 3 chars]: " << endl;90 cin >> walker->symbol;91 periodentafel::AddElement(walker);92 }93 78 return(walker); 94 79 }; … … 99 84 * \return pointer to element 100 85 */ 101 element * periodentafel::FindElement(const char *shorthand) const86 element * const periodentafel::FindElement(const char * const shorthand) const 102 87 { 103 88 element *walker = periodentafel::start; … … 112 97 /** Asks for element number and returns pointer to element 113 98 */ 114 element * periodentafel::AskElement()99 element * const periodentafel::AskElement() const 115 100 { 116 101 element *walker = NULL; … … 124 109 }; 125 110 111 /** Asks for element and if not found, presents mask to enter info. 112 * \return pointer to either present or newly created element 113 */ 114 element * const periodentafel::EnterElement() 115 { 116 element *walker = NULL; 117 int Z = -1; 118 cout << Verbose(0) << "Atomic number: " << Z << endl; 119 cin >> Z; 120 walker = FindElement(Z); 121 if (walker == NULL) { 122 cout << Verbose(0) << "Element not found in database, please enter." << endl; 123 walker = new element; 124 walker->Z = Z; 125 cout << Verbose(0) << "Mass: " << endl; 126 cin >> walker->mass; 127 cout << Verbose(0) << "Name [max 64 chars]: " << endl; 128 cin >> walker->name; 129 cout << Verbose(0) << "Short form [max 3 chars]: " << endl; 130 cin >> walker->symbol; 131 periodentafel::AddElement(walker); 132 } 133 return(walker); 134 }; 135 126 136 /** Prints period table to given stream. 127 137 * \param output stream 128 138 */ 129 bool periodentafel::Output(ofstream * output) const139 bool periodentafel::Output(ofstream * const output) const 130 140 { 131 141 bool result = true; … … 145 155 * \param *checkliste elements table for this molecule 146 156 */ 147 bool periodentafel::Checkout(ofstream * output, const int *checkliste) const157 bool periodentafel::Checkout(ofstream * const output, const int * const checkliste) const 148 158 { 149 159 element *walker = start; … … 215 225 cout << "Could not parse element: "; 216 226 neues->Output((ofstream *)&cout); 227 delete(neues); 217 228 } 218 229 }
Note:
See TracChangeset
for help on using the changeset viewer.