Hello,
I wrote three classes (each in a single file) and wanted to use two of the classes as slots in the first class.
Two of the slots in the unit class are the unit-type and the unit-attributes class.
The unit class:
(1)
If I initialize the unit class with make-instance, do I also have to initialize the slot values of the unit-type and the unit-attributes classes with make-instance?
(2)
These classes are in an adt directory. I read about the packages macro (defpackage) and the in-package method. Where do I have to put the defpackage definition and where do I have to use in-package? I did not really understand the way, where to put the methods and where to load the classes.
Many thanks for any answers.
I wrote three classes (each in a single file) and wanted to use two of the classes as slots in the first class.
Two of the slots in the unit class are the unit-type and the unit-attributes class.
The unit class:
(defclass unit()
((unit-name
:initarg :unit-name
:initform (error "Must supply an unit name.")
:accessor unit-name
:documentation "Name of the unit.")
(unit-race
:initarg :unit-race
:initform (error "Must supply an unit race.")
:accessor unit-race
:documentation "Race of the unit.")
(unit-type
:initarg :unit-type
:initform (error "Must supply an unit type.")
:accessor unit-type
:documentation "Type of the unit.")
(unit-attributes
:initarg :unit-attributes
:initform (error "Must supply unit attributes.")
:accessor unit-attributes
:documentation "The attributes of the unit.")
(unit-size)
(unit-equipment)
(unit-rules)
(unit-options))
(:documentation "A figure or a group of figures that represent one unit."))
The unit-type and the unit-attributes classes:(defclass unit-type()
((name
:initarg :name
:initform (error "Must supply a type name.")
:accessor name
:documentation "Name of the unit."))
(:documentation "Type of the unit like hero, specialist or squad."))
(defclass unit-attributes()
((strength
:initarg :strength
:initform (error "Must supply a strength.")
:accessor strenth
:documentation "Strength of the unit.")
(dexterity
:initarg :dexterity
:initform (error "Must supply a dexterity.")
:accessor dexterity
:documentation "Dexterity of the unit."))
(:documentation "Attributes of the unit like strength, dexterity, etc."))
My questions:(1)
If I initialize the unit class with make-instance, do I also have to initialize the slot values of the unit-type and the unit-attributes classes with make-instance?
(2)
These classes are in an adt directory. I read about the packages macro (defpackage) and the in-package method. Where do I have to put the defpackage definition and where do I have to use in-package? I did not really understand the way, where to put the methods and where to load the classes.
Many thanks for any answers.
"Wenn du nicht irrst, kommst du nicht zu Verstand! Willst du entstehn, entsteh auf eigne Hand!" » FAUST II «
-----
http://www.faustas.de
http://www.makeaims.com
http://www.nebelklar.de
-----
http://www.faustas.de
http://www.makeaims.com
http://www.nebelklar.de