Advertisement
moreiramota

Untitled

Dec 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package lapr.project.model;
  7.  
  8. import lapr.project.data.BicycleDB;
  9.  
  10. /**
  11. *
  12. * @author joaoflores
  13. */
  14. public class Bicycle {
  15.  
  16. int idBicycle;
  17. int type;
  18. String available;
  19.  
  20. public Bicycle(int id_bicycle, int type,String available) {
  21. this.idBicycle = id_bicycle;
  22. this.type = type;
  23. this.available=available;
  24. }
  25.  
  26. public int getId_bicycle() {
  27. return idBicycle;
  28. }
  29.  
  30. public int getType() {
  31. return type;
  32. }
  33.  
  34. public String getAvailable() {
  35. return available;
  36. }
  37. public static void addBicycle(Bicycle b){
  38. new BicycleDB().addBicycle(b);
  39. }
  40.  
  41. public static Bicycle getBicycle(int id) {
  42. return new BicycleDB().getBicycle(id);
  43. }
  44.  
  45. public static int getBicycleType(int id) {
  46. return new BicycleDB().getBicycleType(id);
  47. }
  48.  
  49. public void setIdBicycle(int idBicycle) {
  50. this.idBicycle = idBicycle;
  51. }
  52.  
  53. public void setType(int type) {
  54. this.type = type;
  55. }
  56.  
  57. public void setAvailable(String available) {
  58. this.available = available;
  59. }
  60.  
  61. public boolean save(){
  62. try {
  63. getBicycle(this.idBicycle);
  64. return false;
  65. } catch (IllegalArgumentException ex) {
  66. //Of the record does not exist, save it
  67. new BicycleDB().addBicycle(this);
  68. return true;
  69. }
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement