VSIP/formularium: verschil tussen versies

Uit Wina Examenwiki
Naar navigatie springen Naar zoeken springen
Regel 20: Regel 20:
   name:STRING
   name:STRING
  feature{}                            -- private other: feature{ANY}, feature{NAMECLASS1,NAMECLASS2}
  feature{}                            -- private other: feature{ANY}, feature{NAMECLASS1,NAMECLASS2}
   constructormethod is       
   constructormethod(newname: like name) is       
   do                                  -- start method
   do                                  -- start method
       io.put_string("hello world")    -- do stuff
       name :=  newname    -- do stuff
   end                                -- end constructor
   end                                -- end constructor
  end                                  -- end class NEWCLASS
  end                                  -- end class NEWCLASS

Versie van 10 dec 2008 11:09

Schrijf hier korte voorbeeldjes neer voor elke taal

Smalltalk

Eiffel

toewijzing :          :=
niet gelijk aan :     \=
null:                 Void  
string:               STRING
int:                  INTEGER       
if cond then C1 else C2 end
class
  NEWCLASS                            -- de naam van je klasse
creation
  constructormethod                   -- constructoren aanduiden
feature{}                             -- globale variabelen      
  name:STRING
feature{}                             -- private other: feature{ANY}, feature{NAMECLASS1,NAMECLASS2}
  constructormethod(newname: like name) is       
  do                                  -- start method
     name :=  newname    -- do stuff
  end                                 -- end constructor
end                                   -- end class NEWCLASS

overerving voorbeeld

class
       AUDITORIUM
inherit
       ROOM	
            rename build as build_room end  -- redefine parent method
creation
        build
feature{}
        build(n: like name; p: INTEGER) is -- (arg :like var) or (arg : TYPE) 
        do
               build_room(n, p) -- constructor parent classe aanroepe		
       end
end

C++

C#

Getters en setters:

  • Mogelijkheid 1
private string foo;
public string Foo {
  get { return foo; }
  set { foo = value; }
}
  • Mogelijkheid 2 (C# 3.0+)
public string Foo { get; set; }