Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Inheritence
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
smool




PostPosted: Sat Dec 03, 2011 12:56 pm   Post subject: Inheritence

Basically I try and run my code, and it says "Circular dependency of unit 'Character'" (Character being one of my classes).
I have no idea what this error means, and I have checked over both my Character class and my Me class (Me inherits Character) for any sort of errors but cant find any to my knowledge.
Can someone please explain what this error means? thanks.

Turing:

unit
class Character
    import Item, Weapon, Room, Stuff
    export SetWeapon, Move, SetPosition, x, y, t, weapon

    var x, y, t : real := 0
    var health, maxhealth : real := 70
    var weapon : ^Weapon
    var room : ^Room

    proc SetWeapon (w : ^Weapon)
        weapon := w
    end SetWeapon
end Character



Turing:

unit
class Me
    inherit Character
    import Item, Weapon %, Armor, Consumable
    export NewMe, SetStats, SkillUp, bag


    var name : string := ""
    var level : int := 1
    var intelligence, strength, agility : real := 1
    var mana, maxmana : real := 50
    var healthregain, manaregain : real := 0.5
    var movementspeed : real := 2
    var cooldownreduction : real := 1
    var attackpower, spellpower : int := 0
    var bag : array 1 .. 40 of ^Item
    var armor : ^Item

    proc NewMe (name : string)
        for a : 1 .. 40
            bag (a) := nil
        end for
    end NewMe

    proc SetStats
        maxhealth := 70 + strength * 20
        healthregain := 0.5 + 0.2 * strength
        maxmana := 50 + intelligence * 22
        manaregain := 0.5 + 0.22 * intelligence
        movementspeed := 2 + 0.015 * agility
        cooldownreduction := agility ** (-0.5)
    end SetStats

    proc SkillUp (skill : string)
        case skill of
            label "str" :
                strength += 1
            label "agi" :
                agility += 1
            label "int" :
                intelligence += 1
        end case
        SetStats
    end SkillUp
end Me
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Sat Dec 03, 2011 2:41 pm   Post subject: RE:Inheritence

Does item, weapon, room or stuff import or inherit either one of those?
smool




PostPosted: Tue Dec 06, 2011 6:33 pm   Post subject: RE:Inheritence

ahh. yes, thx Smile room imports character... thanks again Smile
mirhagk




PostPosted: Tue Dec 06, 2011 7:28 pm   Post subject: RE:Inheritence

No problem, the simplest problems cause the most pain.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: