This is why it's generally a good idea to separate implementation and user interface. If you don't want to alter your design, you would need a private static variable which you would increment indefinitely. Still not very clean.

09-27-2006

Rumproast23

you mean.....having the user input how many properties and then try to figure out something from there??

09-27-2006

SlyMaelstrom

Desolation you're really confusing the guy. :)

No, he's talking about your code layout, but forget about that for now... first, so I don't have to compile your code myself, give me an example of what you're getting as output and an example of what you want to get... also, if you don't mind, could you put each example output in it's own code tags?

09-27-2006

Rumproast23

yes to be honest I was confused lol. Remember I may not be bare bottom new but im still really new. I consider this my rough assignment copy Ok ill post my acutal output for you in tags and my wanted output also.

Converting CND into a rental......
This property is now a: RNT
Cost: 6 dollors
Contains: 4 bedrooms
Days On Market: 1 days
Address: 203 lumix vile

I will add 2 more properties later. But I basically thats all im trying to do. My teacher wants me to include get() methods but now that I look at my program it doesnt seem to need them. But I guess i'll leave them there because they are required.

Thanks

09-27-2006

SlyMaelstrom

So for each property type you want a cooresponding number. There are several ways you can do that. The easiest method is likely a method that you can't use for this assignment and that's to use a std::map. For you, the simplest way (and I mean simplest in that it's the lowest level) is to just make a function that returns an int that cooresponds to the type. You can do this with if statements or a switch statement... all you need is to compare a string and return the cooresponding int, then what your output statement should effectively look like is.

Unless, I misunderstood about whether the number cooresponds to the type or if it's just a counter of each property.

09-27-2006

Daved

You could add a member variable that holds an ID and add a different id every time you create a new one in main, but that would put the onus on the calling code in main to figure out what Id to put.

Another option is to do that but add a static member variable like Desolation suggested that increments each time and initializes the ID variable in the constructor.

Another option is to have a function somewhere that knows all the type strings and can return a different ID for each, then you can pass that function your string and it will return the proper ID. This would also be a little less flexible since it would have to know all possible Property types.

09-27-2006

Desolation

Ok I guess I'm not very good at explaining things but there are a few things I'd like to point out. First you include <sstream> yet you never use anything located in this file. Second, you are using strcmp() and such other functions wich are located in <cstring>. You've been lucky that for some reason it was automatically included by your compiler but to be on the safe side, when you use functions on C-style strings like strcmp, strcpy and such, include <cstring>. Third, you put lots of 'using' directives. I suggest you to either put each directive only once, and at the top of the file, after all the includes. Better, each time you use something inside the std namespace, you can access it via std:: . It's a bit longer to write, but it prevents you to fall into some mess that could cause weird compiler bugs. It's something you can easily find when you're used to the language but it's mucho harder when you are struggling with it. Last but not least, if have lots of operations to do on strings, I would suggest you to use C++ style strings which are located in <string> (not <string.h> nor <cstring>). They provide a lot of very useful functions -- like the equality operator -- that will save you lots of time.