Advertisement
spiny94

Untitled

Sep 6th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 KB | None | 0 0
  1. package ticketing;
  2.  
  3. import java.util.LinkedList;
  4. import java.util.List;
  5.  
  6. public class Ticket implements Comparable<Ticket>{
  7.     private Prodotto p;
  8.     private Utente u;
  9.     private String label;
  10.     private long id;
  11.     private long timestamp;
  12.     private Tracker tracker;
  13.     private LinkedList<Commento> commenti = new LinkedList<Commento>();
  14.  
  15.     public Ticket(Tracker tracker, long id, Prodotto p, Utente u, String label) {
  16.         this.tracker = tracker;
  17.         this.id=id;
  18.         this.p = p;
  19.         this.u = u;
  20.         this.label = label;
  21.         this.timestamp = System.currentTimeMillis();
  22.     }
  23.     public long getCodice(){
  24.         return id;
  25.     }
  26.     public Utente getCreatore() {
  27.         return u;
  28.     }
  29.     public Prodotto getProdotto() {
  30.         return p;
  31.     }
  32.     public String getEtichetta() {
  33.         return label;
  34.     }
  35.     public long getTimestamp() {
  36.         return timestamp;
  37.     }
  38.    
  39.     public Commento nuovoCommento(String nick, String testo){
  40.         Utente u = tracker.getUtente(nick);
  41.         Commento c = new Commento(this,u,testo);
  42.         commenti.addFirst(c);
  43.         return c;
  44.     }
  45.  
  46.     public List<Commento> getCommenti(){
  47.         return commenti;
  48.     }
  49.     public int compareTo(Ticket other) {
  50.        
  51.         return (int)(other.timestamp - this.timestamp);
  52.     }
  53. }
  54. package ticketing;
  55.  
  56. public class Utente {
  57.     private String nick,  nome,  email,  pwd;
  58.     private long countTickets;
  59.  
  60.     public Utente(String nick, String nome, String email, String pwd) {
  61.         this.nick = nick;
  62.         this.nome = nome;
  63.         this.email = email;
  64.         this.pwd = pwd;
  65.     }
  66.  
  67.     public String getNickname(){
  68.         return nick;
  69.     }
  70.  
  71.     public String getName(){
  72.         return nome;
  73.     }
  74.    
  75.     public String getEmail(){
  76.         return email;
  77.     }
  78.    
  79.     public boolean authenticate(String pwd){
  80.         return this.pwd.equals(pwd);
  81.     }
  82.  
  83.     public long numeroTicket(){
  84.         return countTickets;
  85.     }
  86.    
  87.     public void addTicket(){
  88.         countTickets++;
  89.     }
  90.    
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement