73 lines
1.5 KiB
Java
73 lines
1.5 KiB
Java
/*
|
|
* 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 library;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
/**
|
|
*
|
|
* @author Agnieszka
|
|
*/
|
|
public class Album extends Item {
|
|
|
|
private String musican;
|
|
|
|
Album() {
|
|
|
|
}
|
|
public Database d = new Database();
|
|
|
|
Album(int id, String n, String m, String y, String c) {
|
|
try {
|
|
this.setYear(Integer.parseInt(y));
|
|
} catch (NumberFormatException e) {
|
|
this.setYear(0);
|
|
}
|
|
this.setId(id);
|
|
this.setName(n);
|
|
this.setCategory(c);
|
|
this.setMusican(m);
|
|
}
|
|
|
|
public static Object[][] insertRowToTable(Object[][] tab, int r, Album a) {
|
|
tab[r][0] = a.getId();
|
|
tab[r][1] = a.getName();
|
|
tab[r][2] = a.getMusican();
|
|
tab[r][3] = a.getYear();
|
|
tab[r][4] = a.getCategory();
|
|
|
|
return tab;
|
|
}
|
|
|
|
@Override
|
|
public void insertToDB() throws SQLException {
|
|
try {
|
|
d.insertAlbumQ(this);
|
|
} catch (SQLException ex) {
|
|
throw new SQLException("Error dodawania albumu");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void delFromDB() throws SQLException {
|
|
d.deleteQ(this);
|
|
}
|
|
|
|
@Override
|
|
public void editInDB() throws SQLException {
|
|
d.updateQ(this);
|
|
}
|
|
|
|
public void setMusican(String s) {
|
|
this.musican = s;
|
|
}
|
|
|
|
public String getMusican() {
|
|
return this.musican;
|
|
}
|
|
|
|
}
|