tuxmartin

Java - abstract/interface ?

Oct 12th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. // Chci udelat "spolecnou tridu":
  2.  
  3. package tvary;
  4.  
  5. import java.awt.Color;
  6. import java.awt.Point;
  7.  
  8. //co pouzit?
  9. //public abstract class Usecka {
  10. public interface Usecka {
  11.     private int x1;
  12.     private int y1;
  13.     private int x2;
  14.     private int y2;
  15.     private Color barva;
  16.    
  17.     public Usecka(Point start, Point cil, Color barva) {       
  18.         this.x1 = start.x;
  19.         this.y1 = start.y;
  20.         this.x2 = cil.x;
  21.         this.y2 = cil.y;
  22.         this.barva = barva;    
  23.     }
  24.    
  25.     public void kresli();
  26.  
  27. }
  28. // a ty jednotlivy usecky by ji nejak pouzivaly
  29. /* ------------------------------------------------------------- */
  30. package tvary;
  31.  
  32. import gui.DrawImage;
  33. import java.awt.Color;
  34. import java.awt.Point;
  35.  
  36. public class UseckaTrivial {
  37.     // ty promenny tu taky nechci
  38.     private int x1;
  39.     private int y1;
  40.     private int x2;
  41.     private int y2;
  42.     private Color barva;
  43.  
  44.     // aby tu nemusel byt kontruktor - pouzil by se ten z Usecka
  45.     public UseckaTrivial(Point start, Point cil, Color barva) {    
  46.         this.x1 = start.x;
  47.         this.y1 = start.y;
  48.         this.x2 = cil.x;
  49.         this.y2 = cil.y;
  50.         this.barva = barva;    
  51.     }
  52.    
  53.     public void kresli() {
  54.         // ...
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment