Advertisement
atanasovetr

Damqn

Jan 26th, 2022
871
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Document</title>
  8. </head>
  9. <body>
  10.     <p id="student1"></p>
  11.     <p id="student2"></p>
  12.  
  13. </body>
  14. <script>
  15.    class DZI{
  16.     constructor(subject1, grade1, subject2, grade2){
  17.         this.subject1 = subject1;
  18.         this.grade1 = grade1;
  19.         this.subject2 = subject2;
  20.         this.grade2 = grade2;
  21.     }
  22.  
  23.     average(){
  24.         return (this.grade1 + this.grade2) / 2;
  25.     }
  26.    }
  27.    var student1 = {name: "Damqn Ivanov", exam: new DZI("BEL", 5.50, "MAT", 6)}
  28.    var student2 = {name: "Yordan Toshev", exam: new DZI("BEL", 4.20, "BIO", 5.30)}
  29.    
  30.    document.getElementById("student1").innerHTML = "Name: " + student1.name + "<br>Average grade: " + student1.exam.average();
  31.    document.getElementById("student2").innerHTML = "Name: " + student2.name + "<br>Average grade: " + student2.exam.average();
  32.  
  33. </script>
  34. </html>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement