Tutorium #1

Softwareentwicklung Praktikum

Gruppe 4 – Michael Schwarz prog-tutor-michael@iicm.tugraz.at
Gruppe 5 – Anja Karl prog-tutor-anja@iicm.tugraz.at
Gruppe 8 – Thomas Neff prog-tutor-thomas@iicm.tugraz.at

Ablauf des Tutoriums

Allgemeines zu den Tutorien


Mitschreiben ist nicht notwendig, die Folien sind online verfügbar

Kontakt

Newsgroups (nntp://news.tugraz.at)

Das Lesen der Newsgroups ist verpflichtend!

E-Mail

Wichtige Internetadressen

Palme (Abgabesystem)

http://palme.iicm.tugraz.at

Wiki

http://palme.iicm.tugraz.at/wiki/SEP

Teach Center

http://tugtc.tugraz.at/wbtmaster/courseMain.htm?706007

Tutoriumshomepage

http://progslides.github.io/ss14/

Leistung




Benotung


Benotungsschema

Arbeitsumgebung

Editor mit Syntaxhighlighting / IDE

kate, gedit, ...
Notepad++
Smultron
Eclipse CDT Sublime

Upload (SFTP) auf Pluto

FileZilla

SSH

Terminal

ssh tugraz_username@pluto.tugraz.at

PuTTY

Compilieren: g++

g++ -Wall -std=c++0x -o ass1 ass1.cpp
g++Name des Compilers
-WallAlle Warnungen anzeigen
-std=c++0xISO C++ 2011 Standard aktivieren
-o ass1Executable als »ass1« speichern
ass1.cppDatei, in welcher der C++ Quelltext steht

Starten:

./ass1

Alternativ: make

make

Starten:

./ass1

Was ist SVN?

SVN einrichten (1/6) : TUGraz online

SVN einrichten (2/6) : Checkout - Windows

TortoiseSVN

SVN verwenden (3/6) : Update/Commit - Windows

SVN verwenden (4/6) : History - Windows

Rechtsklick > TortoiseSVN > Show Log

SVN verwenden (5/6) : Vergleichen - Windows

Log > Show changes

SVN verwenden (6/6) : Linux

KDE-SVN (zu finden im Packet-Manager)

Einfache Klasse (ball.h)

        #ifndef BALL_H_INCLUDED
        #define BALL_H_INCLUDED

        class Ball
        {
        private:
        float x_, y_, speed_;
        int direction_;

        public:
        Ball(float x, float y, float speed, int direction);

        void move();

        float getSpeed();
        void setSpeed(float speed);  
      };

      #endif
    

Konstruktor und move (ball.cpp)

    #include <math.h>
    #include "ball.h"

    Ball::Ball(float x, float y, float speed, int direction) 
    : x_(x), y_(y), speed_(speed)
    {
    direction_ = direction * M_PI / 180.0;
  }

  void Ball::move()
  {
  x_ = x_ + cos(direction_) * speed_;
  y_ = y_ + sin(direction_) * speed_;  
  if(x_ < 0 || x_ > 800) 
  direction_ = atan2(sin(direction_), -cos(direction_));
  if(y_ < 0 || y_ > 600)
  direction_ = atan2(-sin(direction_), cos(direction_));
}

Getter und Setter (ball.cpp)

  // getter Methode für Variable speed_
  float Ball::getSpeed()
  {
  return speed_;
}

// setter Methode für Variable speed_
void Ball::setSpeed(float speed)
{
  speed_ = speed;
}

Das main-Programm

    #include "ball.h"

    int main()
    {
    Ball b1(200, 225, 5, 10);
while(1) { b1.move(); if(b1.getSpeed() < 20) b1.setSpeed(b1.getSpeed() + 0.01);
drawWindow(); // some magic... } }

Häufige Fehler

Live Demo