FrozenSnake's Profile User Rating: -----

Reputation: 122 Stalwart
Group:
Active Members
Active Posts:
990 (0.47 per day)
Joined:
30-July 08
Profile Views:
18,507
Last Active:
User is offline Jan 03 2014 06:50 AM
Currently:
Offline

Previous Fields

Country:
SE
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   FrozenSnake has not set their status

Posts I've Made

  1. In Topic: Decorator pattern, validation of class diagram

    Posted 27 Nov 2013

    View PostSkydiver, on 27 November 2013 - 04:38 PM, said:

    In your diagram, Bottle and Water derives from Beverage, but your code shows otherwise:
    class Beverage: public Bottle {
    
    

    class Water : public Bottle {
    
    

    I guess I should do
    class Bottle: public Beverage {
    
    and
    class Water: public Beverage {
    
    ? =)
    and ofc fix the rest of the code so it use Beverage instead of bottle?
  2. In Topic: What does "[=]" symbolize/mean in this context?

    Posted 30 Aug 2013

    Thanks for the reply and the link! :)
  3. In Topic: Question about pointers with regards to "delete"

    Posted 17 Mar 2013

    Thanks for the help!
  4. In Topic: Question about pointers with regards to "delete"

    Posted 17 Mar 2013

    Should I add a virtual destructor and delete inside these?
    I though I only should use delete when I use new. Is there something I have missed?
    Isn't unique_ptr<> and shared_ptr<> c++11 stuff? My school hasn't started to use c++11 yet so I try to avoid c++11.
  5. In Topic: How to load new (unknown) items from a XML file.

    Posted 23 Jan 2013

    I'll see if I can figure it out.

    This is the function that read the XML document at the moment
    void XMLParser::assign(char tag[], char name[])
    {
    	while(mMyXMLFile && mMyXMLFile->read())
    	{
    		switch(mMyXMLFile->getNodeType())
    		{
    			// irr::io::EXN_ELEMENT
    			case irr::io::EXN_ELEMENT:
    				if(!strcmp(tag, mMyXMLFile->getNodeName()))
    				{
    					// Check for the wanted tag and assign values to the variables.
    					if(tag == "unit" || tag == "building")
    					{
    						std::string temp = mMyXMLFile->getAttributeValue("name");
    						if(temp == name)
    						{
    							mName = mMyXMLFile->getAttributeValue("name");
    							mType = mMyXMLFile->getAttributeValue("type");
    							mTooltip = mMyXMLFile->getAttributeValue("tooltip");
    							mPicture = mMyXMLFile->getAttributeValue("picture");
    							mBuilt = mMyXMLFile->getAttributeValue("built");
    							mTownID = mMyXMLFile->getAttributeValue("townID");
    							mSoundFile = mMyXMLFile->getAttributeValue("sound");
    						}
    					}
    
    					if(tag == "goods")
    					{
    						std::string temp = mMyXMLFile->getAttributeValue("name");
    						if(temp == name)
    						{
    							mName = mMyXMLFile->getAttributeValue("name");
    							mType = mMyXMLFile->getAttributeValue("type");
    							mTooltip = mMyXMLFile->getAttributeValue("tooltip");
    							mPicture = mMyXMLFile->getAttributeValue("picture");
    							mValue = mMyXMLFile->getAttributeValue("value");
    						}
    					}
    				}
    			break;
    
    			case irr::io::EXN_TEXT:
    			break;
    
    			default:
    				break;
    		}	
    	}
    }
    


    goods.cpp
    void Goods::load(char goods[])
    {
    	// What tag are we looking for, and what type of goods?
    	xmlp.assign("goods", goods);
    	
    	//xp.assign("resource");
    	mName = xmlp.getName();
    
    	// convert from string to int.
    	std::istringstream buffer(xmlp.getValue());
    
    	// Put the value inside mBaseValue.
    	buffer >> mBaseValue;
    }
    
    // This one I want to use so I don't have to say which I wanna load
    // but I guess I have to rewrite here and at a few other places.
    void Goods::load()
    {
    	xmlp.assign("goods");
    	mName = xmlp.getName();
    	std::istringstream buffer(xmlp.getValue());
    	buffer >> mBaseValue;
    }
    


    TradeGoods.cpp
    void TradeGoods::pushBack(char goods[])
    {
    	Goods *g = new Goods;
    	g->load(goods); // I want to use g->load();
    	mGoodsVector.push_back(g);
    }
    
    


    Note: I only added the "if(tag == "...")" in tradegoods, and the stuff in them. The other code in the same file is from the example. The pushBack function add the object into a vector<Goods*>, but if I use my

    g->load(); function instead it will only load the last <goods ... /> as many times as I use the pushBack.

    So now it load coal twice instead of food and coal.
    This is the first time I have to do something like this so I am on deep water here. I have tried to find a solution, with no success.

My Information

Member Title:
En man från Sverige!
Age:
29 years old
Birthday:
October 31, 1984
Gender:
Location:
Sweden, Gävle
Full Name:
Kim Wahlman
Years Programming:
8
Programming Languages:
Php, C++

Contact Information

E-mail:
Private
MSN:
MSN  frozensnake@live.se
Website URL:
Website URL  http://
LinkedIn:
http://se.linkedin.com/in/kimwahlman
Twitter:
FrozenSnakeSE
Xfire:
kim.wahlman

Comments

Page 1 of 1
  1. Photo

    Martyn.Rae Icon

    14 Feb 2010 - 04:37
    Davs, hvordan gør det i Sverige?
Page 1 of 1