Traffic 3.1 Examples for Eiffel...
Transcript of Traffic 3.1 Examples for Eiffel...
Traffic 3.1Examples for Eiffel Beginners
Semester Thesis
By: Roger ImbachSupervised by: Michela Pedroni
Prof. Bertrand Meyer
Student Number: 03-914-819
Table of Contents
1 Introduction 3-5
1.1 Personal Motivation 3
1.2 Overview 3
1.3 Scope of the Work 4
1.4 Initial Situation 5
2 Result 6-12
2.1 Road Creation Example 6-8
2.2 Changes in Touch library 8-12
3 Retrospective and future work 13-14
3.1 Retrospective 13
3.2 Future work 14
4 References 15
1 Introduction
1.1 Personal motivation
I can remember the time when I started working with Eiffel at the beginning of the
first semester during the class “Introduction to programming” [1] held by
Bertrand Meyer.
I was impressed by his easy to understand presentation of the core concepts of
software engineering and the well chosen examples, but also shocked by the
complexity of the teaching software “Flat Hunt” and the “Traffic” library [2, 3].
Together with the book “A TOUCH OF CLASS” [4] it was possible to follow the
lecture with the help of some additional examples, but, at least for me, it was
often relatively hard to do the programming exercises with flat hunt.
During the past 2 years some software examples out of the book “A TOUCH OF
CLASS” were implemented into the Traffic software, which, in my eyes, lead to a
better understanding and extended the often complex structure of Traffic / Flat
Hunt in a way that supports our first year students getting to know the concepts.
A good idea which shall be continued in the future ...
1.2 Overview
Bertrand Meyer uses in his class “Introduction to programming”[1] a teaching
approach called the “Inverted Curriculum” [5] which gives students already at the
beginning the opportunity to work with a large amount of software components
(including multimedia and graphics) to activate their curiosity and help them to
understand software in a different and more global way.
Guided by the book “TOUCH OF CLASS” [3], which is constantly in development,
the students see software from a more and more detailed side by “revealing the
magic” with each chapter they read.
This book contains many examples to help the students understand the basic
principles of good software design and these examples are also the subject of
this work.
For the success of the book, it is crucial that the examples are easy to
understand and help the students to get the essence of the concepts.
1.3 Scope of the work
Most of the examples in “TOUCH OF CLASS” are not compatible with the current
Traffic library [3] which makes it more difficult for the students to learn the taught
concepts, because they work with Traffic most of the time. So the key goal of
this semester thesis is to implement some of the examples as close as possible
to the book without destroying the design of the Traffic library or – if it can't be
achieved - to find and implement some new, more suitable examples covering
the same concept. The hope and motivation of this work is to help students to
understand the main concepts in a easy, comprehensible way.
The work included:
– Reading of TOUCH OF CLASS
– Getting familiar with the Traffic library
– Implementing an example focused on the mentioned properties
– Bug fixing and testing
– Documentation
1. 4 Initial situation
The traffic software was written to model and simulate a city and its
transportation system including maps, buildings, traffic lines and travelers.
Sample applications:
– Flat hunt: Implementation of the famous board game “Scotland Yard”.
– City_3D: 3D visualization of the city
– City_time: Introduction of time concept
– City_timetable: Introduction of timetable concept
Implemented TOUCH examples:
– Chapter2_preview: Illustrates feature calls
– Chapter3_commands: Illustrates commands
– Chapter3_queries: Illustrates queries
For more information see [3].
My thesis belongs to the implemented TOUCH examples and extends them
concerning object creation and linking of objects.
2 Result
2.1 Road creation example
The code example above is out of the book “TOUCH OF CLASS” (chapter 6)
covering the concepts of object creation and linking of objects, which are the
concepts I want to describe during this semester thesis. So I decided to
implement this example having in mind the properties the work should have (see
scope of the work).
We see that in this didactic example, ignoring the initialization, there are three
different parts in the code:
1. Object creation and assignment
2. Linking of objects through reference
3. Presentation (using the created line for highlighting)
These three parts are also present in my implementation, although in a slightly
different way.
explore_on_click is-- Create a road and animate it.
docreate places.make
-- Object creationcreate place1.make_with_pos ("Place 1", 50, 50)create place2.make_with_pos ("Place 2", 90, 50)create place3.make_with_pos ("Place 3", 130, 50)create place4.make_with_pos ("Place 4", 170, 50)create place5.make_with_pos ("Place 5", 210, 90)create place6.make_with_pos ("Place 6", 210, 130)create place7.make_with_pos ("Place 7", 210, 170)create place8.make_with_pos ("Place 8", 210, 210)create place9.make_with_pos ("Place 9", 210, 250)create place10.make_with_pos ("Place 10", 90, 150)
-- Linkingplace1.link (place2)place2.link (place3)place3.link (place4)place4.link (place5)place5.link (place6)place6.link (place7)place7.link (place8)place8.link (place9)place9.link (place10)
-- Presentationmap_widget.disable_lines_shown -– Used for better contrastmake_colored_road(place1, 5, 10, 25)
end
2.1.1 Object creation
create place1.make_with_pos ("Place 1", 50, 50)create place2.make_with_pos ("Place 2", 90, 50)create place3.make_with_pos ("Place 3", 130, 50)create place4.make_with_pos ("Place 4", 170, 50)create place5.make_with_pos ("Place 5", 210, 90)create place6.make_with_pos ("Place 6", 210, 130)create place7.make_with_pos ("Place 7", 210, 170)create place8.make_with_pos ("Place 8", 210, 210)create place9.make_with_pos ("Place 9", 210, 250)create place10.make_with_pos ("Place 10", 90, 150)
The object creation is handled in a compact way creating a place object (of type
TOUCH_PLACE, see following explanation) in one step using a name and a x and
y coordinate.
create place.make_with_pos (place_name: STRING; x_coordinate: INTEGER; y_coordinate: INTEGER).
For a more general usage I did not use predefined objects (the original Touch
example) but used coordinates, which also makes testing easier.
2.1.2 Linking objects
place1.link (place2)place2.link (place3)place3.link (place4)place4.link (place5)place5.link (place6)place6.link (place7)place7.link (place8)place8.link (place9)place9.link (place10)
Linking is handled in exactly the same way as in the Touch example (specific
details are discussed later).
2.1.3 Visualization
map_widget.disable_lines_shown -– Used for better contrastmake_colored_road(place1, 5, 10, 25)
The call map_widget.disable_lines_shown is used to get a better view on the
changes adding more contrast between the transportation grid and the map.
For the highlighting of the road the call
make_colored_road(place: TOUCH_PLACE; r_mod: INTEGER; g_mod: INTEGER; b_mod: INTEGER)
is used. Where place is the “starting” place of type TOUCH_PLACE representing
the road (already linked) to be highlighted and r_mod, g_mod, b_mod are
integers indicating modifiers for a coloring of the places of the road with rgb-
colors.
2.2 Changes in the Touch library
TOUCH_PLACE
Is a class that combines TRAFFIC_NODE and TRAFFIC_PLACE providing an easy
way of accessing the two related objects.
A TOUCH_PLACE contains:
t_place: TRAFFIC_PLACE
t_node: TRAFFIC_NODE
next: TOUCH_PLACE
allowing to change traffic places/traffic nodes, which are connected together, via
t.place and t.node, also providing a possibility to link some TOUCH_PLACE,
which can make the creation of different transportation lines (for example a road)
easier.
Linking is made via :
link(a_place: like Current) is-- Links Current place with a_place
donext := a_place
ensure next_set: next = a_place
end
The creation feature of TOUCH_PLACE (like used in the implemented example)
can be seen here:
make_with_pos(a_name: STRING; x,y: INTEGER) is-- Creates a touch place with position x,y
requirename_set: a_name /= Voidinteger_set: x /= Void and y /= Void
localvector : EM_VECTOR_2D
docreate vector.make (x,y)create t_place.make_with_position (a_name,x,y)create t_node.make (t_place, vector)map_widget.map.add_place (t_place)
end
TOUCH_PLACE was also created to showcase the concept of information hiding
(these information are not necessary for the understanding of the implemented
example -> hide this information for increased easiness of the example).
This class can be extended by other features making the interface larger and
access into / manipulating of TRAFFIC_PLACE and TRAFFIC_NODE easier.
TOUCH_SHARED_MAP_WIDGET
This class contains a singleton variable map_widget: TOUCH_3D_MAP_WIDGET.
Map_widget provides a general way of accessing and manipulating a map widget
because it's generated once and is the same for all calls (in the Touch examples
only one map_widget is used).
It can be changed with set-methods or other methods (for example methods
changing representational issues) using a TOUCH_3D_MAP_WIDGET.
In general the TOUCH classes need the representation and therefore the map
widget.
The singleton variable makes it unnecessary to pass the map_widget to every
instance of a TOUCH_... class and therefore, makes it easier to create
transportation lines (for example roads). Can be changed using a set-method.
map_widget: TOUCH_3D_MAP_WIDGET is-- Traffic Map Widget singleton
indexingonce_status: global
oncecreate Result.make
end
TOUCH_ROAD
Like TOUCH_PLACE this class is used for information hiding.
It contains two different creation features, one which creates a “normal” road out
of a list of TOUCH_PLACE and one creating a colored road as used in the road
creation example.
This class can also be extended like TOUCH_PLACE.
Here the second creation feature:
make_colored_road(a_place: TOUCH_PLACE; x: INTEGER; y: INTEGER; z: INTEGER) is
-- Creates a road out of a list of Touch places using x,y,z for coloring of places
localtemp_road : TRAFFIC_ROAD
doif
a_place.next /= Voidthen
create temp_road.make (a_place.t_node, a_place.next.t_node, create {TRAFFIC_TYPE_STREET}.make, 1, "directed")map_widget.map.add_road (temp_road)map_widget.places_representation.highlight_place (a_place.t_place, create {EM_COLOR}.make_with_rgb (x,y,z))make_colored_road(a_place.next, x+5, y+10, z+25)
endend
We see that for creation present and next place are combined to a road and
added to the map (singleton map_widget), plus a coloring of the present place
using the 3 integer values x,y and z as rgb-modifiers and the position in the list
(places are linked) for the creation of the color.
Changes in other classes
In all other classes using a TOUCH_3D_MAP_WIDGET in a feature or a related
object (like a representation) this widget was replaced by the singleton variable
map_widget and all other necessary changes were made.
The other implemented examples were also updated concerning the changes.
3 Retrospective and future work
3.1 Retrospective
Starting the semester project with reading the book and studying the traffic library
since it gave a good basis for selecting adequate examples and estimating
whether they are implementable.
But the initial phase of the work led to more problems than expected, because
there were some other people working on the same software in related classes.
So every couple of days committed changes led to problems concerning my
software development often making it impossible (without external help) to
continue the work. I can not deny that it was quite hard fighting with this
problems, but I'm quite happy I managed (thanks to the help of Michela) to finish
the project. I'm also glad I had the opportunity to make this experience having in
mind that in companies it will probably be comparable.
In retrospective, ignoring the problems with committed wrong code, it was
interesting to work on the traffic library using learned concepts and getting to
know some new ones (singleton variables, factories etc.) and I do not want to
miss this experience.
3.2 Future work
While this semester project helped to increase the support of the examples from
“TOUCH OF CLASS” [4] significantly, a lot of work remains to be done. In
particular, the implementation of examples of higher chapters of “TOUCH OF
CLASS” covering for example genericity and the event-driven design are needed.
These concepts often give first semester students a headache and a well
designed, thought through implementation of these examples can help the
students understand the core of these designs / concepts.
Furthermore, I want to inspire some people to extend my created classes such
as the TOUCH_PLACE or TOUCH_ROAD.
Possible extensions are the widening of the interface of TOUCH_PLACE to extend
the possibilities for manipulating it's contents ->
– Place coloring / animation
– Representational changes
– Querying
– etc.
and the same could be made for TOUCH_ROAD.
In my opinion, it would also be a good step to try generalizing the access on
transportation lines like a route by creating singleton variables for general objects
as was done for map_widget: TOUCH_3D_MAP_WIDGET.
4 References
[1] Found on lecture page : http://se.inf.ethz.ch/teaching/index.html
[2] Flat hunt downloadable from:
http://se.inf.ethz.ch/download/index.html
[3] Traffic: http://traffic.origo.ethz.ch/
[4] Bertrand Meyer: TOUCH OF CLASS, Learning to program well with Object Technology and Design by Contract, AN INTRODUCTION TO SOFTWARE ENGINEERING http://se.inf.ethz.ch/touch
[5] Bertrand Meyer. Towards an object-oriented curriculum. Journal of Object-Oriented Programming, 6(2):76–81, May 1993. Revised version in TOOLS 11
(Technology of object oriented Languages and Systems), eds. R. Edge, M. Singh
and B. Meyer, Prentice Hall, Englewood Cliffs (N.J.), 1993, pages 585-594.
TrafficINDEX >> Overview
Introduction
Traffic is a software system used for teaching introductory programming. It consists of a library - the Traffic library - and several example applications that use the Traffic library: Flathunt,City3D, CityTime, and the Touch applications accompanying the textbook A Touchof Class. The goal of Traffic is to make learning to program exciting, interesting and realistic.
Installation
InstallationGetting started with Traffic
Getting Started Guide
GuideGetting started with Traffic
Traffic library Documentation
Developer DocumentationDeveloper documentation for the Traffic library
Touch library
Developer DocumentationDescriptions of the classes found in the Touch library
Touch examples
Preview, Queries, CommandsDescription of the available examples found in Touch of Class
Traffic 3D example applications
Traffic 3D examplesDescription of the 3d example applications such as City_3D, City_time, City_timetable
Traffic 2D example application
Traffic 2d example: FlathuntUser and developer documentation of the Flathunt application
References
ReferencesReferences to other documents such as thesis reports and webpages
Team
TeamList of people that contributed
INDEX >> Overview
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006-12-14 15:23:55 +0100 (Do, 14 Dez 2006) $
Touch Library ClassesINDEX >> TOUCH LIBRARY >> Overview
Overview over the classes
In the following sections, the classes of the Touch Library are described. Each class description consistsof: Requirements, Description and Class Overview. In the Requirements, the name of classes you needto know, in order to understand the described class is given. Description is a short description of whatthe class does. It is more detailed than just the class description that you find in the class header. TheClass Overview provides a class diagram.
top
Most important classes for developers
TOUCH_BUILDINGTOUCH_CONSOLETOUCH_LINETOUCH_MAPTOUCH_PARIS_OBJECTSTOUCH_ROUTETOUCH_SIMPLE_LINETOUCH_3D_APPLICATIONTOUCH_3D_CONTSTANTSTOUCH_3D_MAP_WIDGETTOUCH_3D_SCENETOURISMTOUCH_PLACETOUCH_SHARED_MAP_WIDGETTOUCH_ROAD
TOUCH_BUILDING
Description
The class represents buildings in a touch application which can be spotlighted and are created at aspecific place.
The features make_at_place takes a traffic_place and the singleton variable map_widget fromTOUCH_SHARED_MAP_WIDGET and creates a building at the location of the place. The center of thebuilding is at (place_position.x, place_position.y + 1).
The other calls are forwarded to the corresponding object of type TRAFFIC_BUILDING.
Class overview
top
TOUCH_CONSOLE
Description
The console displays results of feature calls or ordinary text. It inherits from EM_TEXTAREA which itself isinheriting from EM_TEXTBOX.
The features append_text and put_string append the new text which is passed as string-argument at theend of the text already existing in the console. The feature prepend_text inserts the new text at the beginning of the already present text. Feature show displays the text in the area specified as console.
The console is created in the TOUCH_3D_SCENE and is disabled, that the user can not write into it.
Class overview
top
TOUCH_LINE
Description
The class TOUCH_LINE represents a traffic line in a touch application.
The touch line connects the TRAFFIC_LINE with the singleton variable map_widget fromTOUCH_SHARED_MAP_WIDGET. The calls are forwarded to an object of type TRAFFIC_LINE.
Class overview
top
TOUCH_MAP
Description
This class forwards calls to the TRAFFIC_MAP and the singleton variable map_widget fromTOUCH_SHARED_MAP_WIDGET.
Class overview
top
TOUCH_PARIS_OBJECTS
Description
The class TOUCH_PARIS_OBJECTS is a collection of all predefined objects used by the examples of theTouch of Class book.
The lines and places are singeltons.
To access the predifined objects in TOUCH_PARIS_OBJECTS the map of Paris muest be loaded. The queryprovides information about this
Class overview
top
TOUCH_ROUTE
Description
This class forwards calls to the class TRAFFIC_ROUTE and provides a traveler which travels along theroute.
The feature animate triggers the traveler to travel along the route. After reaching its destination, thetraveler is removed again.
Class overview
top
TOUCH_SIMPLE_LINE
Description
This class forwards calls to the class TRAFFIC_SIMPLE_LINE and its representation.
The creation feature make_with_line_and_represenation takes a TRAFFIC_SIMPLE_LINE and the singleton variable map_widget from TOUCH_SHARED_MAP_WIDGET to set the internal implementationfeatures.
The connection from the line to it's representation (via the singleton variable map_widget) is needed forthe highlighting of the line.
Class overview
Suppliers:
Clients:
top
TOUCH_3D_APPLICATION
Description
The TOUCH_3D_APPLICATION sets the first scene of the example. Feature make initializes the screen and sets the scene. All the individual examples are inheriting from this class.
Class overview
top
TOUCH_3D_CONSTANTS
Description
Here are all the constants defined which are used for the main window. The size of the main window isspecified as well as properties for the objects which are drawn on to the map (for example the line width,the place height, the plane size etc.).
The feature map_to_gl_coords transforms the coordinates specified in the xml file to the coordinates ofthe plane. The Louvre has for example the xml-coordinates ~ (530, 640). Transformed to the planewhich has coordinates between -25 and 25 in both axix, the Louvre has gl-coordinates of ~ (4.9, -1.6).
Class overview
top
TOUCH_3D_MAP_WIDGET
Description
The class TOUCH_3D_MAP_WIDGET adds events and their handlers to the map fromTRAFFIC_3D_MAP_WIDGET.
The following event handlers are added: The wheel_down and wheel_up zoom into, respectively out ofthe map. The mouse_drag rotates the map.
Class overview
top
TOUCH_3D_SCENE
Description
TOUCH_3D_SCENE specifies the widgets which are used for the main window. The feature make creates all buttons and subscribes its event handlers. It furthermore combines the buttons and the console to thepanel at the right side.
All the scenes of the touch examples inherit from this class in order to define its individual scene. Forexample, the PREVIEW_3D_SCENE from the preview example inherits from this class to subscribe theclick_here_button and to create and invoke the example code of preview.
Class overview
top
TOURISM
Description
In this class, the TOUCH_MAP "Paris" is loaded. Features which are used in the individual examples(explore and explore_on_click) are defined as deferred.
The information, which map has been loaded can be retrieved by invoking the feature is_zurich_loadedor is_paris_loaded.
Access to the touch console is given through the feature console. Acces to the map widget is giventhrough the singleton variable map_widget form TOUCH_SHARED_MAP_WIDGET.
The feature run sets the console and invokes explore.
Class overview
top
TOUCH_PLACE
Description
A TOUCH_PLACE contains a TRAFFIC_PLACE and a TRAFFIC_NODE which are created with a name and a position and are inserted into the singleton variable map_widget from TOUCH_SHARED_MAP_WIDGET.
A TOUCH_PLACE can be linked with another TOUCH_PLACE with the feature link.
Class overview
top
TOUCH_SHARED_MAP_WIDGET
Description
Contains a singleton variable map_widget which is used by many classes using aTOUCH_3D_MAP_WIDGET allowing easy access for representational features and a general way ofaccessing maps in the touch applications.
Class overview
top
TOUCH_ROAD
Requirements
NONE
Description
Allows to create a TRAFFIC_ROAD given a list of TOUCH_PLACES. It is possible to create a uncoloredroad using make_road or a colored one using make_colored_road which manipulates the rgb-color of theTRAFFIC_PLACES contained in the TOUCH_PLACE.
Class overview
top
INDEX >> TOUCH LIBRARY >> Overview
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006/03/26 10:54:24 $
Touch-Examples User GuideINDEX >> TOUCH EXAMPLES >> Overview
This document describes how to use the Touch examples and is structured as follows:
How to build a new exampleDescription of how a new Touch example can be built
Mouse and keyboard handling of Touch examplesExplanation of mouse and keyboard usage in the Touch examples
Supported examplesList of supported examples covering differences between the software and the book Touch of Class
INDEX >> TOUCH EXAMPLES >> Overview
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006/03/26 10:54:24 $
Classes Needed for a New ExampleINDEX >> TOUCH EXAMPLES >> new_example
List of required classes
To create and add a new example to the TOUCH_EXAMPLES you have to provide the following 3 classes:
examplenameexamplename_3d_applicationexamplename_3d_scene
The following sections are based on the PREVIEW-example, the first example in the book "A Touch of Class". The neededclasses to create a new example and their relations to the touch library are described.
Overview of the needed Classes(considering the preview-example)
Figure 1: The class relations from the preview example.
EXAMPLENAME: preview
Every example, like the preview example, has to inherit from TOURISM. The class TOURISM contains all the predefined objects needed for the examples.
The feature explore is executed while starting the application. It has to contain the loading of the map.
The second feature explore_on_click contains the code which will be executed after pressing the button "click here". Inthe preview example, the line is highlighted again to have a look at it once more.
class PREVIEW
inherit TOURISM
feature -- Example
explore_on_click is -- Highlight line. do Line8.spotlight endend
top
EXAMPLENAME_3D_APPLICATION: preview_3d_application
PREVIEW_3D_APPLICATION is the root class of the whole example. Inheriting from TOUCH_3D_APPLICATION requires the implementation of the two features set_first_scene and set_application_specifics which are deferred in the super class.
The feature set_first_scene sets the first scene which will be run.
The feature set_application_specifics defines the window title and the application id.
The example code for the preview example looks like this:
class
PREVIEW_3D_APPLICATION
inherit TOUCH_3D_APPLICATION
create make
feature -- Initialization
set_first_scene is -- Set 'scene' to PREVIEW_3D_SCENE. do set_scene (create {PREVIEW_3D_SCENE}.make) end
set_application_specifics is -- Set application specifics. do set_window_title ("Touch - Preview") set_application_id ("Touch_Preview") endend
top
EXAMPLENAME_3D_SCENE: preview_3d_scene
The third class EXAMPLENAME_3D_SCENE, respectively PREVIEW_3D_SCENE makes the first scene and invokes theexamplecode from the corresponding example PREVIEW.
class PREVIEW_3D_SCENE
inherit TOUCH_3D_SCENE redefine initialize_scene end
create make_component_scene
feature -- Interface
initialize_scene is -- Initialize the scene. local preview: PREVIEW do Precursor
create preview preview.run (map_widget)
click_here_button.clicked_event.subscribe (agent preview.explore_on_click) end
end
top
INDEX >> TOUCH EXAMPLES >> new_example
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006/03/26 10:54:24 $
Touch-Examples User GuideINDEX >> TOUCH EXAMPLES >> userguide_main
Touch implements some of the examples of the book ''A Touch of Class''.
How does this application work?
Each chapter respectively each example has its own application. All examples look almost the same, except forsome minor changes to meet the requirements of the individual exercise.
The window contains a square to display the map and a control panel at the right side. The control panelconsists of two parts: One is for navigating throuch the map using for example zoom in or zoom out and theother is the console where possible output is displayed. Dependant on the exercise there are more buttons toclick (for example a restart button etc.).
The button ''click here'' starts the execution of the example.
Figure 1: Example Scene
Navigation
You navigate on the map by pressing the mouse buttons.
Pressing the left mouse button while moving the mouse up or down will lift the map up or push it down.Pressing the right mouse button while moving the mouse will scroll the map.Moving the mouse up or down while pressing the middle mouse button will zoom in or out.Clicking the left mouse button will select places or lines.
INDEX >> TOUCH EXAMPLES >> userguide_main
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006/03/26 10:54:24 $
Supported Touch examplesINDEX >> TOUCH EXAMPLES >> supported_examples
Preview exampleQueries exampleCommands exampleRoad creation example
Preview example
class PREVIEW
inherit
TOURISM
feature -- Example
explore_on_click is -- Execute preview example. do Paris.display Louvre.lighten Route1.animate Line8.spotlight Paris.build Paris.equip Console.show (Line8) Console.show (Place_balard) end
end
Queries example
class QUERIES
inherit
TOURISM
feature -- Example
explore_on_click is -- Show some queries. do Paris.display Console.show (line8.count) Console.show (line8.i_th (1)) Console.show (line8.i_th (line8.count)) end
end
Commands example
class COMMANDS
inherit
TOURISM
feature -- Example
explore_on_click is -- Try some commands. do Paris.display Line8.remove_all_sections Line8.extend_place (Place_la_motte_picquet_grenelle) Line8.extend_place (Place_invalides) Line8.highlight end
end
Road creation example
class ROAD_CREATION inherit TOURISM redefine explore end TOUCH_ROAD feature -- Example explore is -- Some information. do console.set_text ("This is an example of a road creation. C paris.display end explore_on_click is -- Create a road and animate it. do create place1.make_with_pos ("Place 1", 50, 50) create place2.make_with_pos ("Place 2", 90, 50) create place3.make_with_pos ("Place 3", 130, 50) create place4.make_with_pos ("Place 4", 170, 50) create place5.make_with_pos ("Place 5", 210, 90) create place6.make_with_pos ("Place 6", 210, 130) create place7.make_with_pos ("Place 7", 210, 170) create place8.make_with_pos ("Place 8", 210, 210) create place9.make_with_pos ("Place 9", 210, 250) create place10.make_with_pos ("Place 10", 90, 150) place1.link (place2) place2.link (place3) place3.link (place4) place4.link (place5) place5.link (place6) place6.link (place7) place7.link (place8) place8.link (place9) place9.link (place10) map_widget.disable_lines_shown -- Used for better contrast make_colored_road(place1, 5, 10, 25) end end
INDEX >> TOUCH EXAMPLES >> supported_examples
Copyright © 2005, Michela Pedronimailto:[email protected]://traffic.origo.ethz.chLast Updated: $Date: 2006/03/26 10:54:24 $