0
0

More than 3 years have passed since last update.

初心者によるプログラミング学習ログ 155日目

Posted at

100日チャレンジの155日目

twitterの100日チャレンジ#タグ、#100DaysOfCode実施中です。
すでに100日超えましたが、継続。

100日チャレンジは、ぱぺまぺの中ではプログラミングに限らず継続学習のために使っています。

155日目は、

学習したことの一部

practice.js

//メソッド:インスタンスの動作のようなもの
class Book {
    constructor(title, subtitle, number) {
      this.title = title;
      this.number = number;
      this.subtitle = subtitle;
    }

    // booktitle()メソッド追加
    booktitle() {
      console.log("プログラミング本");
    }

    // titlename()メソッド追加
   titlename() {

      //booktitle()メソッド呼び出し
      this.booktitle();

     console.log(`題名は${this.title}です`);
     console.log(`サブタイトルは${this.subtitle}です`);
     console.log(`巻数は${this.number}巻です`);
   }
  }

  const book = new Book("javascript", "初心者向け", 1);

  console.log(`タイトル: ${book.title}`);
  console.log(`サブタイトル: ${book.subtitle}`);
  console.log(`ナンバー: ${book.number}`);


  // bookに対してbooktitleメソッド呼び出し
  //book.booktitle();

// Bookクラスの継承: Novel
class Novel extends Book {
    //getNovelbook()メソッド追加
    getNovelbook() {
        return this.title + this.subtitle;
    }

}
   const novel = new Novel('ruby', '中級者向け', 4);

novel.titlename();

  // title()メソッド呼び出し
  book.titlename();

//定数novelsを定義:定数novelに対してgetNovelbookメソッド呼び出し
 const novels = novel.getNovelbook();

console.log(`本のタイトルは、${novels}です`);


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0