public class Book {
// フィールド
private String title;
private String author;
private int publicationYear;
// コンストラクタ
public Book(String title, String author, int publicationYear) {
this.title = title;
this.author = author;
this.publicationYear = publicationYear;
}
// ゲッターã¨ã‚»ãƒƒã‚¿ãƒ¼
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getPublicationYear() {
return publicationYear;
}
public void setPublicationYear(int publicationYear) {
this.publicationYear = publicationYear;
}
// æƒ…å ±ã‚’è¡¨ç¤ºã™ã‚‹ãƒ¡ã‚½ãƒƒãƒ‰
public void displayInfo() {
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("Publication Year: " + publicationYear);
}
}
ã“ã®ä¾‹ã§ã¯ã€Book クラスãŒã‚¿ã‚¤ãƒˆãƒ«ã€è‘—者ã€å‡ºç‰ˆå¹´ã‚’ä¿æŒã—ã€ãれãžã‚Œã®æƒ…å ±ã‚’å–å¾—ãŠã‚ˆã³è¨å®šã™ã‚‹ãŸã‚ã®ã‚²ãƒƒã‚¿ãƒ¼ã¨ã‚»ãƒƒã‚¿ãƒ¼ã‚’æä¾›ã—ã¦ã„ã¾ã™ã€‚ã¾ãŸã€displayInfo() メソッドを使用ã—ã¦ã€ã™ã¹ã¦ã®æƒ…å ±ã‚’ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã«è¡¨ç¤ºã™ã‚‹æ–¹æ³•も示ã—ã¦ã„ã¾ã™ã€‚è‡ªåˆ†ã§æ‰‹ã‚’å‹•ã‹ã—ã¦ã€ã“ã®ä¾‹ã‚’ã‚‚ã¨ã«å®Ÿéš›ã®ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚°ã‚’行ã£ã¦ã¿ã¦ãã ã•ã„。
「007 クラスã€å•題集リスト
🎯 実習ã§ç†è§£ã‚’æ·±ã‚よã†
ã“ã®å†…容ã«ã¤ã„ã¦JavaDrillã§å®Ÿéš›ã«æ‰‹ã‚’å‹•ã‹ã—ã¦å¦ç¿’ã§ãã¾ã™


コメント