Wo sind meine Fahrzeuge
							parent
							
								
									3bd5464fe6
								
							
						
					
					
						commit
						f70f07ffbd
					
				
							
								
								
									
										35
									
								
								Auto.java
								
								
								
								
							
							
						
						
									
										35
									
								
								Auto.java
								
								
								
								
							|  | @ -1,31 +1,10 @@ | |||
| 
 | ||||
| /** | ||||
|  * Beschreiben Sie hier die Klasse Auto. | ||||
|  *  | ||||
|  * @author (Ihr Name)  | ||||
|  * @version (eine Versionsnummer oder ein Datum) | ||||
|  */ | ||||
| import java.util.Random; | ||||
| public class Auto | ||||
| class Auto extends Fahrzeug | ||||
| { | ||||
|     int raeder;  | ||||
|     String farbe; | ||||
|      | ||||
|     public Auto(int r, String f){ | ||||
|     Random rand = new Random(); | ||||
|     raeder = rand.nextInt(8); | ||||
|     farbe = f;        | ||||
|     } | ||||
|      | ||||
|     private void hupe(){ | ||||
|         System.out.println("Hup-Hup!"); | ||||
|     } | ||||
|      | ||||
|     public void setzeRaeder(int r){ | ||||
|         raeder = r; | ||||
|     } | ||||
|      | ||||
|     public void ausgabe(){ | ||||
|         System.out.println("Ich bin ein " + farbe + "es Auto!"); | ||||
|     } | ||||
|     public Auto(){ | ||||
|         super(140, 4); | ||||
| } | ||||
|     protected Auto(double m ){ | ||||
|     super (m, 4); | ||||
| } | ||||
| } | ||||
|  | @ -0,0 +1,31 @@ | |||
| 
 | ||||
| /** | ||||
|  * Beschreiben Sie hier die Klasse Auto. | ||||
|  *  | ||||
|  * @author (Ihr Name)  | ||||
|  * @version (eine Versionsnummer oder ein Datum) | ||||
|  */ | ||||
| import java.util.Random; | ||||
| public class Auto_alt | ||||
| { | ||||
|     int raeder;  | ||||
|     String farbe; | ||||
|      | ||||
|     public Auto_alt(int r, String f){ | ||||
|     Random rand = new Random(); | ||||
|     raeder = rand.nextInt(8); | ||||
|     farbe = f;        | ||||
|     } | ||||
|      | ||||
|     private void hupe(){ | ||||
|         System.out.println("Hup-Hup!"); | ||||
|     } | ||||
|      | ||||
|     public void setzeRaeder(int r){ | ||||
|         raeder = r; | ||||
|     } | ||||
|      | ||||
|     public void ausgabe(){ | ||||
|         System.out.println("Ich bin ein " + farbe + "es Auto!"); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,8 @@ | |||
| 
 | ||||
| public class Fahrrad extends Fahrzeug | ||||
| { | ||||
|     public Fahrrad(){ | ||||
|         super(30, 2); | ||||
|          | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,32 @@ | |||
| 
 | ||||
| public class Fahrzeug | ||||
| { | ||||
|     private double position; | ||||
|     private double speed; | ||||
|     private double max; | ||||
|     private int wheels; | ||||
|      | ||||
|     public void bewege( double time){ | ||||
|         this.position += speed*time/60; | ||||
|     } | ||||
|      | ||||
|     public void setSpeed(double s ) { | ||||
|         this.speed = s; | ||||
|         if (this.speed > this.max) this.speed = this.max; | ||||
|     } | ||||
|      | ||||
|     public double getMaxSpeed(){ | ||||
|         return this.max; | ||||
|     } | ||||
|      | ||||
|     public int getWheelCount(){ | ||||
|         return this.wheels; | ||||
|     } | ||||
|      | ||||
|     public Fahrzeug(double m, int w){ | ||||
|         this.position = 0; | ||||
|         this.speed = 0; | ||||
|         this.max = m; | ||||
|         this.wheels = w; | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,18 @@ | |||
| 
 | ||||
| 
 | ||||
| public class Krankenwagen extends Auto | ||||
| { | ||||
|     private boolean blaulicht; | ||||
|     public Krankenwagen(){ | ||||
|         super(); | ||||
|          | ||||
|         blaulicht = false; | ||||
|     } | ||||
|     public void turnOn() | ||||
|     { | ||||
|         blaulicht = true; | ||||
|     } | ||||
|     public void turnOff(){ | ||||
|         blaulicht = false; | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,7 @@ | |||
| 
 | ||||
| public class Rennwagen extends Auto | ||||
| { | ||||
|     public Rennwagen(){ | ||||
|         super(220); | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue