Advertisement
julibar

Aporte 1 - clase Categoria - Punto 2 del TP

May 7th, 2025
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. //archivo Categoria.java
  2.  
  3. package Paquete;
  4.  
  5. public class Categoria {
  6.        
  7.     private static int proxId = 0;
  8.     private final int id;
  9.     private String nombre;
  10.    
  11.    
  12.     public Categoria() {
  13.         super();
  14.         proxId = proxId + 1;
  15.         id = proxId;
  16.         nombre = "Sin definir";
  17.     }
  18.    
  19.    
  20.     public Categoria(String nombre) {
  21.         super();
  22.         proxId = proxId + 1;
  23.         id = proxId;
  24.         this.nombre = nombre;
  25.     }
  26.  
  27.  
  28.     public String getNombre() {
  29.         return nombre;
  30.     }
  31.  
  32.  
  33.     public void setNombre(String nombre) {
  34.         this.nombre = nombre;
  35.     }
  36.  
  37.  
  38.     public int getId() {
  39.         return id;
  40.     }
  41.  
  42.  
  43.     @Override
  44.     public String toString() {
  45.         return nombre;
  46.     }
  47.            
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement