<?xml version="1.0" encoding="UTF-8"?>
<class name="Item" extends="Thing" extends-java="Thing" enable="true" strideversion="1">
    <javadoc xml:space="preserve"/>
    <imports>
        <import target="java.util.*" enable="true"/>
        <import target="greenfoot.*" enable="true"/>
        <import target="javax.swing.*" enable="true"/>
    </imports>
    <implements/>
    <fields>
        <variable access="protected" type="int" type-java="int" name="value" enable="true"/>
        <variable access="protected" type="Prinzessin" type-java="Prinzessin" name="prinzessin" enable="true"/>
    </fields>
    <constructors>
        <constructor access="public" enable="true">
            <javadoc xml:space="preserve"/>
            <params/>
            <throws/>
            <body>
                <call expression="super(2)" expression-java="super(2)" enable="true"/>
                <assign dest="this.value" dest-java="this.value" src="(Greenfoot.getRandomNumber(10)+1)*100" src-java="(Greenfoot.getRandomNumber(10) + 1) * 100" enable="true"/>
            </body>
        </constructor>
    </constructors>
    <methods>
        <method access="protected" type="void" type-java="void" name="addedToWorld" enable="true">
            <javadoc xml:space="preserve"/>
            <params>
                <param type="World" type-java="World" name="world"/>
            </params>
            <throws/>
            <body>
                <call expression="world.addObject(new Textbox(this.getClass().getSimpleName()+&quot;: &quot;+this.value+&quot;$&quot;,new Font(&quot;Rockwell&quot;,true,false,14),new Color(230,250,230),200,50),this.getX(),this.getY()+50)" expression-java="world.addObject( new Textbox(this.getClass().getSimpleName() + &quot;: &quot; + this.value + &quot;$&quot;, new Font(&quot;Rockwell&quot;, true, false, 14), new Color(230, 250, 230), 200, 50), this.getX(), this.getY() + 50)" enable="true"/>
            </body>
        </method>
        <method access="public" type="void" type-java="void" name="act" enable="true">
            <javadoc xml:space="preserve">Act - do whatever the Item wants to do. This method is called whenever the 'Act' or 'Run' button gets pressed in the environment.</javadoc>
            <params/>
            <throws/>
            <body>
                <if condition="Greenfoot.mouseClicked(this)" condition-java="Greenfoot.mouseClicked(this)" enable="true">
                    <ifStatements>
                        <variable type="Prinzessin" type-java="Prinzessin" name="prinzessin" value="(Prinzessin)this.getWorld().getObjects(Prinzessin.class).get(0)" value-java="(Prinzessin)this.getWorld().getObjects(Prinzessin.class).get(0)" enable="true"/>
                        <if condition="this.value&gt;prinzessin.getCredit()" condition-java="this.value &gt; prinzessin.getCredit()" enable="true">
                            <ifStatements>
                                <comment xml:space="preserve">not enought credits to buy item</comment>
                                <variable type="String" type-java="String" name="text" value="&quot;Zu wenig Geld (&quot;+prinzessin.getCredit()+&quot;$)\nBenötigt: &quot;+this.value+&quot;$&quot;" value-java="&quot;Zu wenig Geld (&quot; + prinzessin.getCredit() + &quot;$)\nBenötigt: &quot; + this.value + &quot;$&quot;" enable="true"/>
                                <variable type="String" type-java="String" name="title" value="&quot;Problem!&quot;" value-java="&quot;Problem!&quot;" enable="true"/>
                                <call expression="Message.showDialog(text,title)" expression-java="Message.showDialog(text, title)" enable="true"/>
                            </ifStatements>
                            <else>
                                <call expression="prinzessin.setCredit(prinzessin.getCredit()-this.value)" expression-java="prinzessin.setCredit(prinzessin.getCredit() - this.value)" enable="true"/>
                                <call expression="prinzessin.addToInventory(this)" expression-java="prinzessin.addToInventory(this)" enable="true"/>
                                <variable type="String" type-java="String" name="inventoryItems" value="&quot;&quot;" value-java="&quot;&quot;" enable="true"/>
                                <foreach type="Item" type-java="Item" var="item" collection="prinzessin.getInventory()" collection-java="prinzessin.getInventory()" enable="true">
                                    <assign dest="inventoryItems" dest-java="inventoryItems" src="&quot;\n* &quot;+inventoryItems+item.getClass().getSimpleName()+&quot; *&quot;" src-java="&quot;\n* &quot; + inventoryItems + item.getClass().getSimpleName() + &quot; *&quot;" enable="true"/>
                                </foreach>
                                <call expression="Message.showDialog(&quot;Gekauft: &quot;+this.getClass().getSimpleName()+&quot; für &quot;+this.value+&quot;$\nSie besitzen:&quot;+inventoryItems+&quot;\nSie haben jetzt noch &quot;+prinzessin.getCredit()+&quot;\nGehen Sie in Ihr Haus, um es einzurichten&quot;,&quot;Erfolgreicher Kauf!&quot;)" expression-java="Message.showDialog(&quot;Gekauft: &quot; + this.getClass().getSimpleName() + &quot; für &quot; + this.value + &quot;$\nSie besitzen:&quot; + inventoryItems + &quot;\nSie haben jetzt noch &quot; + prinzessin.getCredit() + &quot;\nGehen Sie in Ihr Haus, um es einzurichten&quot;, &quot;Erfolgreicher Kauf!&quot;)" enable="true"/>
                                <call expression="this.getWorld().removeObject(this)" expression-java="this.getWorld().removeObject(this)" enable="true"/>
                            </else>
                        </if>
                    </ifStatements>
                </if>
            </body>
        </method>
    </methods>
</class>
