Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.magicced01.test;
- public class Kraftfahrzeug {
- private int gewicht;
- public Kraftfahrzeug(int gewicht) {
- this.setGewicht(gewicht);
- }
- public int getGewicht() {
- return gewicht;
- }
- public void setGewicht(int gewicht) {
- this.gewicht = gewicht;
- }
- }
- package me.magicced01.test;
- public class Auto extends Kraftfahrzeug{
- private int geschwindigkeit;
- public Auto(int gewicht, int geschwindigkeit) {
- super(gewicht);
- this.geschwindigkeit = geschwindigkeit;
- // TODO Auto-generated constructor stub
- }
- public int getGeschwindigkeit() {
- return geschwindigkeit;
- }
- public void setGeschwindigkeit(int geschwindigkeit) {
- this.geschwindigkeit = geschwindigkeit;
- }
- }
- package me.magicced01.test;
- public class Main {
- public static void main(String args[]) {
- Auto auto = new Auto(1000,100);
- System.out.println(auto.getGewicht());
- System.out.println(auto.getGeschwindigkeit());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement