Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <html>
  2. <script>
  3. var isNorm=true;
  4. var date=new Date();
  5. class User {
  6. constructor(name, surname) {
  7. this.name = name;
  8. this.surname = surname;
  9. }
  10. getInfo() {
  11. if(this.isNorm)
  12. return this.name + ' ' + this.surname;
  13. else
  14. return "Студент не числится"
  15. }
  16. }
  17. class Student extends User{
  18. constructor(name, surname,year=date.getFullYear()) {
  19. super(name,surname);
  20. this.year=year;
  21. this.isNorm = arguments.length !== 2;
  22. }
  23. enroll() {
  24. if (!this.isNorm){
  25. this.isNorm=true;
  26. }else
  27. throw "Уже зачислен";
  28. }
  29. expel(){
  30. this.isNorm=false;
  31. }
  32. GetCurse() {
  33. var a =date.getFullYear(parseInt())-this.year;
  34. if(this.isNorm&&a<=6)
  35. return a+1;
  36. else
  37. return "Студент не числится"
  38. }
  39. getInfo() {
  40. if(this.isNorm)
  41. return this.name + ' ' + this.surname+ ' Студент '+this.GetCurse()+" курса";
  42. else
  43. return "Студент не числится"
  44. }
  45. }
  46. var student = new Student("Жека","Ахмедов");
  47.  
  48.  
  49. console.log(student.getInfo());
  50. </script>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement