Skip to topic | Skip to bottom
Home
Minfo
Minfo.SeLab1r1.5 - 10 Oct 2012 - 16:31 - KrikavaFiliptopic end

Start of topic | Skip to actions

Lab 1 : Set up, building with ant

PhilippeCollet

Introduction

In this Lab we will go over some of the basics of the Eclipse IDE and the Apache Ant build tool. We will also introduce the running example application that will be used through the course.

Prerequisites

  • Installed Java SDK
  • Installed Eclipse
  • Installed Ant

Exercise: Getting started with the creature simulator

The initial code is provided in the http://deptinfo.unice.fr/twiki/pub/Minfo/SeLab1/tp1-resources.zip archive.

This code contains an application that creates an little framework for simulating creatures. A creature is basically just an object that has some properties (like position, direction, speed, color, ...) and behavior. It can act - change its properties and it knows how to render itself on a graphical canvas. In this lab version, a creature has also a vision. It can see other creatures within certain field of view and a certain distance.

The framework is built on the top of Java Swing library.

Starting with the creature simulator

  1. Create a new Java project in Eclipse
  2. Correctly place the given source files
  3. Make sure you have no errors in the Problems view
  4. Go over the classes to get the notion about how it works

Ant in Eclipse

Ant in Command Line

Exercise: Refactor manifest creation in ant

The way how the manifest is made in the build.xml is rather complicated. There is actually a http://ant.apache.org/manual/Tasks/manifest.html? in Ant so you should rewrite the appropriate code to you this one instead. Think also about the lifecycle of the manifest during the build and that perhaps you should modify other targets. Lastly, when checking whether it works, make sure you first delete all the META-INF and MANIFEST.MF files.

Exercise: Smart creature

The goal of this exercise is to create a new kind of creature is a bit smarter than the stupid one. It should have following behavior:

  1. It should try to align its speed with the speed of the creatures around.
  2. It should go in the same direction as the creatures around.
  3. It should maintain some minimal distance from the creatures around.

Exercise: Code analysis of the creature simulator

The given code is not well written. Now you will play a role of a senior software developer whose task is to review a code that has been produce by some junior. Try to come up with as many improvements as possible. For example:

  • What to do with some of the utility functions?
  • What to do with the fact that logic of the Environment and the visualization are kept together?
  • ...

Appendix

Coordinates and Angles

Overview of the coordinate system. We use the common Euclidian two-dimensional geometry with the coordinate system origin in the middle of the plane.

graphicalSystem.png

Method directionFromAPoint() in AbstractCreature

Explanation of the directionFromAPoint() method.

directionFromAPoint.png

Method: creaturesAround() in Environment

What is considered to be a creature near by.

creaturesAround.png

Method: act() in SmartCreature

The position change based on computed speed and direction.

increment.png

-- KrikavaFilip - 09 Oct 2012
to top

I Attachment sort Action Size down Date Who Comment
build.xml manage 1.8 K 10 Oct 2012 - 15:10 KrikavaFilip Solution for the ant manifest refactoring
SmartCreature.java manage 2.5 K 10 Oct 2012 - 15:10 KrikavaFilip Solution for the smart creature exercise
tp1-resources.zip manage 5.6 K 09 Oct 2012 - 23:29 KrikavaFilip Source code for the TP1

You are here: Minfo > SeLab1

to top

Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WIKIDeptinfo? Send feedback