1 #include <iostream>
  2 #include <sstream>
  3 #ifndef PHARM_H
  4 #include "pharm.h"
  5 #define PHARM_H
  6 #endif
  7 #ifndef EXCEPT_H
  8 #define EXCEPT_H
  9 #include <stdexcept>
 10 #include <cstdlib>
 11 #endif
 12
 13
 14 Bugtrap::Bugtrap() : runtime_error("Error Bulding Constructor")
 15 {
 16
 17         cerr << what();
 18 //      exit(1);
 19
 20 }
 21
 22 Bugtrap::Bugtrap(const string errormsg) :  runtime_error(errormsg.c_str())
 23 {
 24         cerr << what();
 25 //      exit(1);
 26
 27 }
 28
 29 Bugtrap::Bugtrap(const string errormsg, const string file, const string line) : runtime_error(errormsg.c_str())
 30 {
 31         cerr << what();
 32         cerr << "Error file: " << file << "and line: " << line;
 33         cerr << "exiting now";
 34 //      exit(1);
 35
 36 }
 37
 38 DOSEING::DOSEING(){
 39         string errormsg;
 40         try
 41         {
 42         weight_ = 0.0;
 43         height_ = 0.0;
 44         srcr_ = 0.0;
 45         age_ = 0;
 46         gender_ = 'U';
 47         lbw_ = 0.0;
 48         first_ = "noone";
 49         last_ = "nobody";
 50         address_ = "nowhere";
 51         crcl_ = crcl();
 52         }catch (string errormsg){
 53                 ostringstream otmp;
 54                 otmp << __LINE__;
 55                 string line = otmp.str();
 56                 otmp << __FILE__ ;
 57                 string file = otmp.str();
 58                 Bugtrap bug( string errormsg, string file,  string line);
 59                 cout << bug.what() <<endl;
 60         }              
 61
 62 }
 63
 64
 65 DOSEING::DOSEING( float weight, float height, int age, char gen){
 66         try
 67         {
 68         weight_ = weight;
 69         height_ = height;
 70         srcr_ = 0.0;
 71         age_ = age;
 72         gender_ = gen;
 73         lbw_ = 0.0;
 74         first_ = "noone";
 75         last_ = "nobody";
 76         address_ = "nowhere";
 77         crcl_ = crcl();
 78         }
 79         catch (string errormsg){
 80                 ostringstream otmp;
 81                 otmp << __LINE__;
 82                 string line = otmp.str();
 83                 otmp << __FILE__ ;
 84                 string file = otmp.str();
 85                 Bugtrap bug(string errormsg, string file, string line);
 86         }              
 87
 88
 89 }
 90
 91 DOSEING::DOSEING( string weight, string height, int age, char gen){
 92         try
 93         {
 94         weight_ = weight;
 95         height_ = height;
 96         srcr_ = 0.0;
 97         age_ = age;
 98         gender_ = gen;
 99         lbw_ = 0.0;
100         first_ = "noone";
101         last_ = "nobody";
102         address_ = "nowhere";
103         crcl_ = crcl();
104         }
105         catch (string errormsg){
106                 ostringstream otmp;
107                 otmp << __LINE__;
108                 string line = otmp.str();
109                 otmp << __FILE__ ;
110                 string file = otmp.str();
111                 Bugtrap bug(string errormsg, string file, string line);
112         }              
113
114
115 }
116 DOSEING::DOSEING( float weight, float height, int age, char gen, float srcr){
117         try{
118         weight_ = weight;
119         height_ = height;
120         srcr_ = srcr;
121         age_ = age;
122         gender_ = gen;
123         lbw_ = 0.0;
124         first_ = "noone";
125         last_ = "nobody";
126         address_ = "nowhere";
127         crcl_ = crcl();
128         }
129         catch (string errormsg){
130                 ostringstream otmp;
131                 otmp << __LINE__;
132                 string line = otmp.str();
133                 otmp << __FILE__ ;
134                 string file = otmp.str();
135                 Bugtrap bug(string errormsg, string file, string line);
136         }              
137
138 }
139
140 DOSEING::DOSEING( string weight, string height, int age, char gen, float srcr){
141         try{
142         weight_ = weight;
143         height_ = height;
144         srcr_ = srcr;
145         age_ = age;
146         gender_ = gen;
147         lbw_ = 0.0;
148         first_ = "noone";
149         last_ = "nobody";
150         address_ = "nowhere";
151         crcl_ = crcl();
152         }
153         catch (string errormsg){
154                 ostringstream otmp;
155                 otmp << __LINE__;
156                 string line = otmp.str();
157                 otmp << __FILE__ ;
158                 string file = otmp.str();
159                 Bugtrap bug(string errormsg, string file, string line);
160         }              
161
162 }
163 DOSEING::DOSEING( string first, string last, float weight, float height, int age, char gen){
164         try{
165         weight_ = weight;
166         height_ = height;
167         srcr_ = 0.0;
168         age_ = age;
169         gender_ = gen;
170         lbw_ = 0.0;
171         first_ = first;
172         last_ = last;
173         address_ = "nowhere";
174         crcl_ = crcl();
175         }
176         catch (string errormsg){
177                 ostringstream otmp;
178                 otmp << __LINE__;
179                 string line = otmp.str();
180                 otmp << __FILE__ ;
181                 string file = otmp.str();
182                 Bugtrap bug(string errormsg, string file, string line);
183         }              
184
185
186
187 }
188         
189         
190 DOSEING::DOSEING( string first, string last, string weight, string height, int age, char gen){
191         try{
192         weight_ = weight;
193         height_ = height;
194         srcr_ = 0.0;
195         age_ = age;
196         gender_ = gen;
197         lbw_ = 0.0;
198         first_ = first;
199         last_ = last;
200         address_ = "nowhere";
201         crcl_ = crcl();
202         }
203         catch (string errormsg){
204                 ostringstream otmp;
205                 otmp << __LINE__;
206                 string line = otmp.str();
207                 otmp << __FILE__ ;
208                 string file = otmp.str();
209                 Bugtrap bug(string errormsg, string file, string line);
210         }              
211
212
213 }
214
215 DOSEING::DOSEING( string first, string last, float weight, string height, int age, char gen){
216         try
217         {
218                 weight_ = weight;
219                 height_ = height;
220                 srcr_ = 0.0;
221                 age_ = age;
222                 gender_ = gen;
223                 lbw_ = 0.0;
224                 first_ = first;
225                 last_ = last;
226                 address_ = "nowhere";
227                 crcl_ = crcl();
228         }
229         catch (string errormsg){
230                 ostringstream otmp;
231                 otmp << __LINE__;
232                 string line = otmp.str();
233                 otmp << __FILE__ ;
234                 string file = otmp.str();
235                 Bugtrap bug(string errormsg, string file, string line);
236         }              
237
238 }
239
240 DOSEING::DOSEING( string first, string last, string weight, float height, int age, char gen){
241         try
242         {
243                 weight_ = weight;
244                 height_ = height;
245                 srcr_ = 0.0;
246                 age_ = age;
247                 gender_ = gen;
248                 lbw_ = 0.0;
249                 first_ = first;
250                 last_ = last;
251                 address_ = "nowhere";
252                 crcl_ = crcl();
253         }
254         catch (string errormsg){
255                 ostringstream otmp;
256                 otmp << __LINE__;
257                 string line = otmp.str();
258                 otmp << __FILE__ ;
259                 string file = otmp.str();
260                 Bugtrap bug(string errormsg, string file, string line);
261         }              
262
263 }
264
265 DOSEING::DOSEING( string first, string last, float weight, float height, int age, char gen, float srcr){
266         try
267         {
268                 weight_ = weight;
269                 height_ = height;
270                 srcr_ = srcr;
271                 age_ = age;
272                 gender_ = gen;
273                 lbw_ = 0.0;
274                 first_ = first;
275                 last_ = last;
276                 address_ = "nowhere";
277                 crcl_ = crcl();
278         }
279         catch (string errormsg){
280                 ostringstream otmp;
281                 otmp << __LINE__;
282                 string line = otmp.str();
283                 otmp << __FILE__ ;
284                 string file = otmp.str();
285                 Bugtrap bug(string errormsg, string file, string line);
286         }              
287
288 }
289 DOSEING::DOSEING( string first, string last,  string weight, string height, int age, char gen, float srcr){
290         try
291         {
292                 weight_ = weight;
293                 height_ = height;
294                 srcr_ = srcr;
295                 age_ = age;
296                 gender_ = gen;
297                 lbw_ = 0.0;
298                 first_ = first;
299                 last_ = last;
300                 address_ = "nowhere";
301                 crcl_ = crcl();
302         }
303         catch (string errormsg){
304                 ostringstream otmp;
305                 otmp << __LINE__;
306                 string line = otmp.str();
307                 otmp << __FILE__ ;
308                 string file = otmp.str();
309                 Bugtrap bug(string errormsg, string file, string line);
310         }              
311
312 }
313 DOSEING::DOSEING( string first, string last,  float weight, string height, int age, char gen, float srcr){
314         try
315         {
316                 weight_ = weight;
317                 height_ = height;
318                 srcr_ = srcr;
319                 age_ = age;
320                 gender_ = gen;
321                 lbw_ = 0.0;
322                 first_ = first;
323                 last_ = last;
324                 address_ = "nowhere";
325                 crcl_ = crcl();
326         }
327         catch (string errormsg){
328                 ostringstream otmp;
329                 otmp << __LINE__;
330                 string line = otmp.str();
331                 otmp << __FILE__ ;
332                 string file = otmp.str();
333                 Bugtrap bug(string errormsg, string file, string line);
334         }              
335
336 }
337 DOSEING::DOSEING( string first, string last,  string weight, float height, int age, char gen, float srcr){
338         try
339         {
340                 weight_ = weight;
341                 height_ = height;
342                 srcr_ = srcr;
343                 age_ = age;
344                 gender_ = gen;
345                 lbw_ = 0.0;
346                 first_ = first;
347                 last_ = last;
348                 address_ = "nowhere";
349                 crcl_ = crcl();
350         }
351         catch (string errormsg){
352                 ostringstream otmp;
353                 otmp << __LINE__;
354                 string line = otmp.str();
355                 otmp << __FILE__ ;
356                 string file = otmp.str();
357                 Bugtrap bug(string errormsg, string file, string line);
358         }              
359
360 }
361 DOSEING::DOSEING( string first, string last, string address, float weight, float height, int age, char gen){
362         try{
363                 weight_ = weight;
364                 height_ = height;
365                 srcr_ = 0.0;
366                 age_ = age;
367                 gender_ = gen;
368                 lbw_ = 0.0;
369                 first_ = first;
370                 last_ = last;
371                 address_ = address;
372                 crcl_ = crcl();
373         }
374         catch (string errormsg){
375                 ostringstream otmp;
376                 otmp << __LINE__;
377                 string line = otmp.str();
378                 otmp << __FILE__ ;
379                 string file = otmp.str();
380                 Bugtrap bug(string errormsg, string file, string line);
381         }              
382
383 }
384
385 DOSEING::DOSEING( string first, string last, string address, string weight, string height, int age, char gen){
386         try
387         {
388                 weight_ = weight;
389                 height_ = height;
390                 srcr_ = 0.0;
391                 age_ = age;
392                 gender_ = gen;
393                 lbw_ = 0.0;
394                 first_ = first;
395                 last_ = last;
396                 address_ = address;
397                 crcl_ = crcl();
398         }
399         catch (string errormsg){
400                 ostringstream otmp;
401                 otmp << __LINE__;
402                 string line = otmp.str();
403                 otmp << __FILE__ ;
404                 string file = otmp.str();
405                 Bugtrap bug(string errormsg, string file, string line);
406         }              
407 }
408
409 DOSEING::DOSEING( string first, string last, string address, float weight, string height, int age, char gen){
410         try
411         {
412                 weight_ = weight;
413                 height_ = height;
414                 srcr_ = 0.0;
415                 age_ = age;
416                 gender_ = gen;
417                 lbw_ = 0.0;
418                 first_ = first;
419                 last_ = last;
420                 address_ = address;
421                 crcl_ = crcl();
422         }
423         catch (string errormsg){
424                 ostringstream otmp;
425                 otmp << __LINE__;
426                 string line = otmp.str();
427                 otmp << __FILE__ ;
428                 string file = otmp.str();
429                 Bugtrap bug(string errormsg, string file, string line);
430         }              
431 }
432 DOSEING::DOSEING( string first, string last, string address, string weight, float height, int age, char gen){
433         try{
434                 weight_ = weight;
435                 height_ = height;
436                 srcr_ = 0.0;
437                 age_ = age;
438                 gender_ = gen;
439                 lbw_ = 0.0;
440                 first_ = first;
441                 last_ = last;
442                 address_ = address;
443                 crcl_ = crcl();
444         }
445         catch (string errormsg){
446                 ostringstream otmp;
447                 otmp << __LINE__;
448                 string line = otmp.str();
449                 otmp << __FILE__ ;
450                 string file = otmp.str();
451                 Bugtrap bug(string errormsg, string file, string line);
452         }              
453 }
454
455
456 DOSEING::DOSEING( string first, string last, string address, float weight, float height, int age, char gen, float srcr){
457         try
458         {
459                 weight_ = weight;
460                 height_ = height;
461                 srcr_ = srcr;
462                 age_ = age;
463                 gender_ = gen;
464                 lbw_ = 0.0;
465                 first_ = first;
466                 last_ = last;
467                 address_ = address;
468                 crcl_ = crcl();
469         }
470         catch (string errormsg){
471                 ostringstream otmp;
472                 otmp << __LINE__;
473                 string line = otmp.str();
474                 otmp << __FILE__ ;
475                 string file = otmp.str();
476                 Bugtrap bug(string errormsg, string file, string line);
477         }              
478 }
479
480 DOSEING::DOSEING( string first, string last, string address,  string weight, string height, int age, char gen, float srcr){
481         try
482         {
483                 weight_ = weight;
484                 height_ = height;
485                 srcr_ = srcr;
486                 age_ = age;
487                 gender_ = gen;
488                 lbw_ = 0.0;
489                 first_ = first;
490                 last_ = last;
491                 address_ = address;
492                 crcl_ = crcl();
493         }
494         catch (string errormsg){
495                 ostringstream otmp;
496                 otmp << __LINE__;
497                 string line = otmp.str();
498                 otmp << __FILE__ ;
499                 string file = otmp.str();
500                 Bugtrap bug(string errormsg, string file, string line);
501         }              
502 }
503
504 DOSEING::DOSEING( string first, string last, string address,  float weight, string height, int age, char gen, float srcr){
505         try
506         {
507                 weight_ = weight;
508                 height_ = height;
509                 srcr_ = srcr;
510                 age_ = age;
511                 gender_ = gen;
512                 lbw_ = 0.0;
513                 first_ = first;
514                 last_ = last;
515                 address_ = address;
516                 crcl_ = crcl();
517         }
518         catch (string errormsg){
519                 ostringstream otmp;
520                 otmp << __LINE__;
521                 string line = otmp.str();
522                 otmp << __FILE__ ;
523                 string file = otmp.str();
524                 Bugtrap bug(string errormsg, string file, string line);
525         }              
526 }
527
528 DOSEING::DOSEING( string first, string last, string address,  string weight, float height, int age, char gen, float srcr){
529         try
530         {
531                 weight_ = weight;
532                 height_ = height;
533                 srcr_ = srcr;
534                 age_ = age;
535                 gender_ = gen;
536                 lbw_ = 0.0;
537                 first_ = first;
538                 last_ = last;
539                 address_ = address;
540                 crcl_ = crcl();
541         }
542         catch (string errormsg){
543                 ostringstream otmp;
544                 otmp << __LINE__;
545                 string line = otmp.str();
546                 otmp << __FILE__ ;
547                 string file = otmp.str();
548                 Bugtrap bug(string errormsg, string file, string line);
549         }              
550 }
551
552 float DOSEING::crcl()
553 {
554         float w = weight();
555         float h = height();
556         float a = age();
557         float sr = srcr();
558         char g = gender();
559         float ibw, num, den, cc;
560
561         if ((g == 'M') || (g == 'm') )
562         {
563
564                 ibw = 50 + 2.3 * (h - 60);
565                 if(h < 61)
566                         ibw = w;
567         }else{
568                 if ((g == 'F') || (g == 'f') )
569                 {
570                  ibw = 45 + 2.3 * (h - 60);
571                 if(h < 61)
572                         ibw = w;
573                 }else{
574                         return 0.0;
575                 }
576         }
577
578
579         num = (140 - a) * ibw;
580         den = (72 * sr);
581         try
582         {
583                 if (den == 0.0)
584                         throw Zero();
585         }
586         catch(Zero serum){
587                 cout << serum.what() << endl;
588                 cc = 0.0;
589                 return cc;
590         }
591         cc = num/den;
592         return cc;
593 }
594
595
596
597
598
599
600
601
602
603         
604
605 //Weight Class Definition
606
607 Weight::Weight() { wgt(0.0); }
608
609 Weight::Weight(const float fwgt_) { wgt(fwgt_); }
610
611 Weight::Weight(const float fwgt_, const string &funit_){
612         try {
613                 wgt(fwgt_, funit_);
614         }
615         catch (string errormsg){
616                 cout << "Error:  Units error - can\'t determine type " << errormsg;
617                 cout << "\n" << "Setting Weight to 70 Kilograms";
618                 wgt_ = 70;
619                 unit_ = "kg";
620         }
621
622 }
623
624 Weight::Weight(const string &fdesc_){
625         try {
626                 wgt(fdesc_);
627         }
628         catch (string errormsg){
629                 cout << "Error:  Units error - can\'t determine type " << errormsg;
630                 cout << "\n" << "Setting Weight to 70 Kilograms";
631                 wgt_ = 70;
632                 unit_ = "kg";
633         }
634
635 }
636
637 Weight::Weight(const Weight &fweight)
638 {
639         //No choice but to hope it is in kilograms
640 //CHANGE THIS to take unit from receiving object (which should be kg always)    
641         unit_ = "kg";
642         wgt_ = fweight.wgt();
643 }
644
645 float Weight::wgt(const float fwgt_)
646 {
647         //No choice but to hope it is in kilograms
648         
649         unit_ = "kg";
650         wgt_ = fwgt_;
651         return wgt_;
652 }
653
654 float Weight::wgt(const float fwgt_, const string &funit_)
655 {
656         string errormsg("ERROR: enter either \"kilograms\" or \"pounds\"");
657         if( funit_ == "kg" || funit_ == "k" || funit_ == "kilo" || funit_ == "kilogram"|| funit_ == "kilograms"){
658                 unit_ = "kg";
659                 wgt_ = fwgt_;
660         }else if( funit_ == "lb" || funit_ == "pound" || funit_ == "pd"|| funit_ == "pounds" ){
661                 wgt_ = fwgt_ * 0.45454545;
662         }else{
663                 throw errormsg;
664         }
665         return wgt_;
666 }
667
668 float Weight::wgt(const string &descr)
669 {
670         string errormsg("ERROR: enter a number followed by either \"kilograms\" or \"pounds\"");
671         istringstream stream1;
672         stream1.str(descr);
673         if (!(stream1>>wgt_))
674                 throw errormsg;
675         if(!(stream1>>unit_))
676                 throw errormsg;
677         errormsg = "ERROR: enter either \"kilograms\" or \"pounds\"";
678         if( unit_ == "kg" || unit_ == "k" || unit_ == "kilo" || unit_ == "kilogram"|| unit_ == "kilograms"){
679                 unit_ = "kg";
680         }else if( unit_ == "lb" || unit_ == "pound" || unit_ == "pd"|| unit_ == "pounds" ){
681                 wgt_ = wgt_ * 0.45454545;
682         }else{
683                 throw errormsg;
684         }
685         return wgt_;
686 }
687         
688
689
690 float Weight::operator=(const float fwgt_)
691 {
692         //No choice but to hope it is in kilograms
693         
694         unit_ = "kg";
695         wgt_ = fwgt_;
696         return wgt_;
697 }
698
699
700 //FIX THIS TO BE LIKE STRING
701
702 float Weight::operator=(const char * fwgt_)
703 {
704         try
705         {
706                 wgt_ = wgt(fwgt_);
707         }
708         catch (string errormsg){
709                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
710                 cout << "\n" << "Setting Weight to 70 Kilograms\n";
711                 wgt_ = 70;
712                 unit_ = "kg";
713         }
714
715         return wgt_;
716 }
717
718 float Weight::operator=(const string &fwgt_)
719 {
720         try
721         {
722                 wgt_ = wgt(fwgt_);
723         }
724         catch(string errormsg)
725         {
726                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
727                 cout << "\n" << "Setting Weight to 70 Kilograms\n";
728                 wgt_ = 70;
729                 unit_ = "in";
730         }
731
732         return wgt_;
733 }
734
735
736 // Height Class Definition
737
738 Height::Height() { hgt(0.0); }
739
740 Height::Height(const float fhgt_) { hgt(fhgt_); }
741
742 Height::Height(const float fhgt_, const string &funit_){
743         try {
744                 hgt(fhgt_, funit_);
745         }
746         catch (string errormsg){
747                 cout << "Error:  Units error - can\'t determine type " << errormsg;
748                 cout << "\n" << "Setting Height to 68 inches";
749                 hgt_ = 68;
750                 unit_ = "in";
751         }
752
753 }
754
755
756 Height::Height(const Height &fheight)
757 {
758         //No choice but to hope it is in inches
759         
760         unit_ = "in";
761         hgt_ = fheight.hgt();
762 }
763
764 Height::Height(const string &fdesc_)
765 {
766         try {
767                 hgt(fdesc_);
768         }
769         catch (string errormsg){
770                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
771                 cout << "\n" << "Setting Height to 68 inches\n";
772                 hgt_ = 68;
773                 unit_ = "in";
774         }
775 }
776
777
778
779
780 //Height::hgt ==> convets everything to height in inches
781
782
783 float Height::hgt(const float fhgt_)
784 {
785         //No choice but to hope it is in inches
786         
787         unit_ = "in";
788         hgt_ = fhgt_;
789         return hgt_;
790 }
791
792 float Height::hgt(const float fhgt_, const string &funit_)
793 {
794         string errormsg("ERROR: enter either \"inches\" or \"meters\"");
795         if( funit_ == "meters"||funit_ == "meter" || funit_ == "m" || funit_ == "mt" || funit_ == "mtr"|| funit_ == "mt"){
796                 unit_ = "in";
797                 hgt_ = fhgt_ * 39.37;
798         }else if( funit_ == "in" || funit_ == "inch" || funit_ == "i"|| funit_ == "inches" ){
799                 unit_ = "in";
800                 hgt_ = fhgt_;
801         }else{
802                 errormsg.append(" :You entered =>");
803                 errormsg.append(funit_);
804                 throw errormsg;
805         }
806         return hgt_;
807 }
808
809
810 //takes height in as a single string and breaks it down to quantity and units.
811 //units converted to inches
812
813 float Height::hgt(const string &descr)
814 {
815         string errormsg("ERROR: enter a number followed by either \"inches\" or \"meters\"\n");
816         errormsg.append(":You entered =>");
817         istringstream stream1;
818         try
819         {
820                 stream1.str(descr);
821                 if (!(stream1>>hgt_))
822                 {
823                         errormsg.append(descr);
824                         throw errormsg;
825                 }
826                 if(!(stream1>>unit_))
827                 {
828                         errormsg.append(descr);
829                         throw errormsg;
830                 }
831                 if( unit_ == "meters"|unit_ == "meter" || unit_ == "m" || unit_ == "mt" || unit_ == "mtr"|| unit_ == "mt")
832                 {
833                         unit_ = "in";
834                         hgt_ = hgt_ * 39.37;
835         
836                 }else if( unit_ == "in" || unit_ == "inch" || unit_ == "i"|| unit_ == "inches" ){
837                         unit_ = "in";
838                 }else{
839                         errormsg.append(":You entered =>");
840                         errormsg.append(descr);
841                         throw errormsg;
842                 }
843         }
844         catch (string errormsg){
845                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
846                 cout << "\n" << "Setting Height to 68 inches\n";
847                 hgt_ = 68;
848                 unit_ = "in";
849         }
850         return hgt_;
851 }
852         
853 float Height::hgt(const char *tmp)
854 {
855         string errormsg("ERROR: enter a number followed by either \"inches\" or \"meters\"\n");
856         string descr = tmp;
857         errormsg.append(":You entered =>");
858         istringstream stream1;
859         stream1.str(descr);
860         if (!(stream1>>hgt_))
861         {
862                 errormsg.append(descr);
863                 throw errormsg;
864         }
865         if(!(stream1>>unit_))
866         {
867                 errormsg.append(descr);
868                 throw errormsg;
869         }
870         if( unit_ == "meters"|unit_ == "meter" || unit_ == "m" || unit_ == "mt" || unit_ == "mtr"|| unit_ == "mt")
871         {
872                 unit_ = "in";
873                 hgt_ = hgt_ * 39.37;
874
875         }else if( unit_ == "in" || unit_ == "inch" || unit_ == "i"|| unit_ == "inches" ){
876                 unit_ = "in";
877         }else{
878                 errormsg.append(":You entered =>");
879                 errormsg.append(descr);
880                 throw errormsg;
881         }
882         return hgt_;
883 }
884         
885
886
887 float Height::operator=(const float fhgt_)
888 {
889         //No choice but to hope it is in inches
890         
891         unit_ = "in";
892         hgt_ = fhgt_;
893         return hgt_;
894 }
895
896 //char array must be hgt in inches
897 //Since the assignment operator can only take one argument then unlike the constructor there is no point
898 //in allowing it to be a string of two words or 2 seperate symbols.
899
900 float Height::operator=(const char * fhgt_)
901 {
902         try
903         {
904                 hgt_ = hgt(fhgt_);
905         }
906         catch (string errormsg){
907                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
908                 cout << "\n" << "Setting Height to 68 inches\n";
909                 hgt_ = 68;
910                 unit_ = "in";
911         }
912
913         return hgt_;
914 }
915
916 float Height::operator=(const string &fhgt_)
917 {
918         try
919         {
920                 hgt_ = hgt(fhgt_);
921         }
922         catch(string errormsg)
923         {
924                 cout << "Error:  Units error - can\'t determine type\n" << errormsg;
925                 cout << "\n" << "Setting Height to 68 inches\n";
926                 hgt_ = 68;
927                 unit_ = "in";
928         }
929
930         return hgt_;
931 }
932
933
934
935
936
937
938
939
940
941
942
943