forked from mouredev/hello-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.java
More file actions
32 lines (26 loc) · 703 Bytes
/
Copy pathBook.java
File metadata and controls
32 lines (26 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package basic.c08_oop;
// Definición de la clase Book
class Book {
private String title;
private String author;
// Constructor
public Book(String title, String author) {
this.title = title;
this.author = author;
}
// Getter para el título (solo lectura)
public String getTitle() {
return title;
}
// Getter y setter opcionales para el autor
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
// Método para mostrar los datos del libro
public void showInfo() {
System.out.println("Título: " + title + ", Autor: " + author);
}
}