Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package lapr.project.model;
- import lapr.project.data.BicycleDB;
- /**
- *
- * @author joaoflores
- */
- public class Bicycle {
- int idBicycle;
- int type;
- String available;
- public Bicycle(int id_bicycle, int type,String available) {
- this.idBicycle = id_bicycle;
- this.type = type;
- this.available=available;
- }
- public int getId_bicycle() {
- return idBicycle;
- }
- public int getType() {
- return type;
- }
- public String getAvailable() {
- return available;
- }
- public static void addBicycle(Bicycle b){
- new BicycleDB().addBicycle(b);
- }
- public static Bicycle getBicycle(int id) {
- return new BicycleDB().getBicycle(id);
- }
- public static int getBicycleType(int id) {
- return new BicycleDB().getBicycleType(id);
- }
- public void setIdBicycle(int idBicycle) {
- this.idBicycle = idBicycle;
- }
- public void setType(int type) {
- this.type = type;
- }
- public void setAvailable(String available) {
- this.available = available;
- }
- public boolean save(){
- try {
- getBicycle(this.idBicycle);
- return false;
- } catch (IllegalArgumentException ex) {
- //Of the record does not exist, save it
- new BicycleDB().addBicycle(this);
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement