Last active
April 16, 2019 18:46
-
-
Save kevinunger/20997a72b9cb37ba0c4a3a473dd2c52d to your computer and use it in GitHub Desktop.
Punkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Punkt | |
{ | |
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variabln | |
public int x; | |
public int y; | |
/** | |
* Konstruktor für Objekte der Klasse Punkt | |
*/ | |
public Punkt() | |
{ | |
int x; | |
int y; | |
} | |
//Konstruktor 1 nimmt x_eingabe und y_eingabe entgegen und setzt diese in x,y ein | |
public Punkt(int x , int y){ | |
this.x = x; | |
this.y = y; | |
System.out.println("x ist jetzt: " + x + "y ist jetzt: " + y); | |
} | |
public int getX () | |
{ | |
// tragen Sie hier den Code ein | |
return x; | |
} | |
public int getY() | |
{ | |
// tragen Sie hier den Code ein | |
return y; | |
} | |
void setX (int X){ | |
x = X; | |
} | |
void setY (int Y){ | |
y = Y; | |
} | |
void aktuellePositionAusgeben(){ | |
System.out.println("X: "+ x + " " + "Y1: " + y); | |
} | |
void bewegenUm (int dx, int dy){ | |
setX(x + dx); | |
setY(y + dy); | |
} | |
public double gibAbstand(int x2, int y2){ | |
int x1 = getX(); | |
int y1 = getY(); | |
return Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2)); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Beschreiben Sie hier die Klasse Rechteck. | |
* | |
* @author (Ihr Name) | |
* @version (eine Versionsnummer oder ein Datum) | |
*/ | |
import java.awt.Color; | |
public class Rechteck | |
{ | |
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen | |
public int breite; | |
public int laenge; | |
public String bezeichnung; | |
public float r,g,b; | |
Color farbe = new Color(r,g,b); | |
Punkt position = new Punkt(); | |
/** | |
* Konstruktor für Objekte der Klasse Rechteck | |
*/ | |
//Konstruktor 1 | |
public Rechteck() | |
{ | |
// Instanzvariable initialisieren | |
} | |
//Konstruktor 2 | |
public Rechteck(Punkt position, int breite, int laenge, String bezeichnung, Color farbe){ | |
} | |
void bewegeUm (int dx, int dy){ | |
position.x = position.x + dx; | |
position.y = position.y + dy; | |
} | |
void bewegeUm (Punkt andererPunkt){ | |
} | |
void ausgabeAttribute(){ | |
System.out.printf("Breite: , Rechteck.breite"); | |
} | |
//SET Methoden | |
void setBreite(int breite_input){ | |
breite = breite_input; | |
} | |
void setLaenge(int laenge_input){ | |
laenge = laenge_input; | |
} | |
void setPosition(Punkt position_input){ | |
position = position_input; | |
} | |
void setBezeichung(String bezeichnung_input){ | |
bezeichnung = bezeichnung_input; | |
} | |
void setFarbe(float R,float G,float B){ | |
farbe = new Color(R,G,B); | |
} | |
//GET Methoden | |
public int getBreite() { | |
return breite; | |
} | |
public int getLaenge(){ | |
return laenge; | |
} | |
public String bezeichnung(){ | |
return bezeichnung; | |
} | |
public Color farbe(){ | |
return farbe; | |
} | |
public Punkt position(){ | |
return position; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Kevin | |
*/ | |
public class Spielfeld { | |
int width = 1000; | |
int length = 1000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment