MDC:Sample interface document
From MDC
The nsICookieMonster interface is a make-believe interface that eats and enjoys cookies. This is an example of what an interface document should look like; however, it's not a document about a real interface.
Contents |
nsICookieMonster is defined in toolkit/components/cookies/public/nsICookieMonster.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 9.5.0).
Inherits from: nsICookieFan
Implemented by: @mozilla.org/cookie-monster;1. To create an instance, use:
var cookieMonster = Components.classes["@mozilla.org/cookie-monster;1"]
.createInstance(Components.interfaces.nsICookieMonster);
[edit] Method overview
void eatCookie(in nsICookie cookieToEat);
|
AString getFunnySaying(in integer number);
|
void sayYummy(in AString language);
|
void sing();
|
[edit] Attributes
| Attribute | Type | Description |
favoriteCookie
| integer
| The cookie monster's favorite kind of cookie. Must be one of the constants defined under Constants on this page. |
hungerLevel
| integer
| A value from 0-100 indicating how hungry the cookie monster is. 0 means "stuffed to the brim with cookies" and 100 means "I'm so empty of cookies! Feed me now!" |
name
| AString
| The cookie monster's name. |
[edit] Constants
| Constant | Value | Description |
COOKIE_FLAVOR_SUGAR
| 1 | Simple sugar cookie. |
COOKIE_FLAVOR_CHOCOLATE_CHIP
| 2 | Chocolate chip cookie. |
COOKIE_FLAVOR_PEANUT_BUTTER
| 3 | Peanut butter cookie. |
COOKIE_FLAVOR_DOUBLE_CHOCOLATE
| 4 | Chocolate cookie with chocolate chips. |
COOKIE_FLAVOR_OTHER
| 0 | An unknown type of cookie. |
[edit] Methods
[edit] eatCookie()
Feeds a cookie to the cookie monster.
void eatCookie( in nsICookie cookieToEat );
[edit] Parameters
- cookieToEat
- The cookie to eat.
[edit] getFunnySaying()
Returns a string containing a funny quote the cookie monster might say.
AString getFunnySaying( in integer number );
[edit] Parameters
- number
- The saying number to return.
[edit] Return value
An AString containing the requested funny quote. If the specified quote number is invalid, an exception is thrown.
[edit] Exceptions thrown
- NS_ERROR_FAILURE
- Unable to locate the requested quote.
[edit] sayYummy()
Says something appreciative of the tastiness of the cookie in the specified language.
void sayYummy( in AString language );
[edit] Parameters
- language
- The localization identification indicating the language in which the cookie monster is to express his love of cookies.
[edit] sing()
Sings the song "C is For Cookie."
void sing();
[edit] Parameters
None.
[edit] Remarks
Remember, this isn't a real interface. This is where you would provide additional information about the interface as necessary.
[edit] See also
The line below is commented-out using "nowiki" tags in this example, to keep it from appearing in the interface list; however, in a real document, you should remove those nowiki tags and remove this paragraph.
[[Category:Interfaces]]