JoshuaStrutt

Datenbank

Sep 28th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.06 KB | None | 0 0
  1.  
  2. public abstract class  Artikel {
  3.    
  4.     protected String name = "" ;
  5.     protected long id = 0;
  6.     protected double preis = 0;
  7.     public String getName() {
  8.         return name;
  9.     }
  10.     public void setName(String name) {
  11.         this.name = name;
  12.     }
  13.     public long getId() {
  14.         return id;
  15.     }
  16.     public void setId(long id) {
  17.         this.id = id;
  18.     }
  19.     public double getPreis() {
  20.         return preis;
  21.     }
  22.     public void setPreis(int preis) {
  23.         this.preis = preis;
  24.     }
  25.     public Bewertung getBewertung() {
  26.         return bewertung;
  27.     }
  28.     public void setBewertung(Bewertung bewertung) {
  29.         this.bewertung = bewertung;
  30.     }
  31.     protected Bewertung bewertung;
  32.    
  33. }
  34.  
  35. import java.awt.Color;
  36.  
  37.  
  38. public class Erzeuger {
  39.  
  40.     public static void main(String[] args) {
  41.        
  42.         Datenbank d = new Datenbank();
  43.  
  44.         Film harryPotter1 = new Film();
  45.         harryPotter1.setBewertung(Bewertung.SEHRGUT);
  46.         harryPotter1.setBeschreibung("Der britisch-US-amerikanische Fantasyfilm Harry Potter und der Stein der Weisen ist "
  47.                 + "die Verfilmung des ersten Romans der Harry-Potter-Kinderbuchreihe.");
  48.         harryPotter1.setName("Harr Potter und der Stein der Weisen");
  49.         harryPotter1.setPreis(10);
  50.         harryPotter1.setId(12318);
  51.         harryPotter1.setRegisseur("Chris Columbus");
  52.        
  53.         Handy motoXPlay = new Handy();
  54.         motoXPlay.setBewertung(Bewertung.GUT);
  55.         motoXPlay.setMarke("Motorola");
  56.         motoXPlay.setModell("X Play");
  57.         motoXPlay.setName("Moto X Play");
  58.         motoXPlay.setFarbe(Color.black);
  59.         motoXPlay.setPreis(350);
  60.         motoXPlay.setId(31233);
  61.        
  62.         d.addArtikel(harryPotter1);
  63.         d.addArtikel(motoXPlay);
  64.        
  65.     }
  66.  
  67. }
  68.  
  69.  
  70. public enum Bewertung {
  71.     UNGENUEGEND,MANGELHAFT,AUSREICHEND,BEFRIEDIGEND,GUT,SEHRGUT
  72. }
  73.  
  74. import java.util.ArrayList;
  75.  
  76.  
  77. public class Film extends Artikel{
  78.    
  79.     private String regisseur = "";
  80.     private ArrayList<String> schauspieler = new ArrayList<String>();
  81.     private String beschreibung =  "";
  82.     public String getRegisseur() {
  83.         return regisseur;
  84.     }
  85.     public void setRegisseur(String regisseur) {
  86.         this.regisseur = regisseur;
  87.     }
  88.     public ArrayList<String> getSchauspieler() {
  89.         return schauspieler;
  90.     }
  91.     public void setSchauspieler(ArrayList<String> schauspieler) {
  92.         this.schauspieler = schauspieler;
  93.     }
  94.     public String getBeschreibung() {
  95.         return beschreibung;
  96.     }
  97.     public void setBeschreibung(String beschreibung) {
  98.         this.beschreibung = beschreibung;
  99.     }
  100.    
  101.    
  102. }
  103.  
  104. import java.util.ArrayList;
  105.  
  106.  
  107. public class Datenbank {
  108.    
  109.     private ArrayList<Artikel> artikel = new ArrayList<Artikel>();
  110.     public void addArtikel(Artikel a){
  111.         artikel.add(a);
  112.     }
  113.     public void rtikel(Artikel a){
  114.         artikel.remove(a);
  115.     }
  116.    
  117. }
  118.  
  119. import java.awt.Color;
  120.  
  121.  
  122. public class Handy extends Artikel{
  123.    
  124.     public String getMarke() {
  125.         return Marke;
  126.     }
  127.     public void setMarke(String marke) {
  128.         Marke = marke;
  129.     }
  130.     public String getModell() {
  131.         return Modell;
  132.     }
  133.     public void setModell(String modell) {
  134.         Modell = modell;
  135.     }
  136.     public Color getFarbe() {
  137.         return Farbe;
  138.     }
  139.     public void setFarbe(Color farbe) {
  140.         Farbe = farbe;
  141.     }
  142.     private String Marke = "";
  143.     private String Modell = "";
  144.     private Color Farbe = Color.black;
  145.    
  146. }
Add Comment
Please, Sign In to add comment