sergAccount

Untitled

Aug 23rd, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.87 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.spec;
  7.  
  8. import com.spec.model.Institute;
  9. import com.spec.model.Student;
  10.  
  11. /**
  12.  *
  13.  * @author Admin
  14.  */
  15. public class Main {
  16.     //
  17.     public static void printStudent(Student s){
  18.         if(s!=null){
  19.             System.out.println("s.name=" + s.getName());
  20.             System.out.println("s.age="  + s.getAge());
  21.         }
  22.     }
  23.     // main + tab
  24.     public static void main(String[] args) {
  25.         // Ctrl+Shift+I - хот кей для добавления оператора импорта
  26.         Student s;
  27.         // что можно присвоить переменной s - ???
  28.         // 1) null - ссылка на пустоту
  29.         s = null;
  30.         System.out.println("s=" + s);
  31.         // 2) можем присвоить объект
  32. //        s = new Student();
  33. //        //
  34. //        Student s2 = new Student();
  35. //        // выводим имя студента - вызвыаем метод getName на объекте s2
  36. //        System.out.println("s2.name="   + s2.getName());
  37. //        System.out.println("s2.getAge=" + s2.getAge());
  38.  
  39.         s = new Student("Alex", 10);
  40.         Student s2 = new Student("Nick", 20);
  41.         // что мы можем сделать с объектом s2 ???
  42.         // вывести на экран студента (s2)
  43.         //System.out.println("s2=" + s2);        
  44.         System.out.println("s2=" + s2.getName() + "_" + s2.getAge());
  45.         //
  46.         Student s3 = null;
  47.         // вывести на экран имя и возраст студента s3        
  48. //        boolean res = (s == null);
  49. //        res = (s != null);        
  50.         if(s3!=null){
  51.             System.out.println("s3=" + s3.getName() + "_" + s3.getAge());
  52.         }                
  53.         printStudent(s3);
  54.        
  55. //        Student.setInstituteCode(1011);
  56. //        Student.setInstituteCode(1012);
  57. //        //
  58. //        System.out.println("s.getInstituteCode()="  + Student.getInstituteCode());
  59. //        System.out.println("s3.getInstituteCode()=" + Student.getInstituteCode());                        
  60.         //        
  61.         //
  62.         s.setInstituteCode(Institute.INSTITUTE1);
  63.         s2.setInstituteCode(Institute.INSTITUTE2);
  64.        
  65.         System.out.println("s.iCode=" + s.getInstituteCode());
  66.         System.out.println("s2.iCode=" + s2.getInstituteCode());
  67.        
  68.         System.out.println("OK");        
  69.        
  70.         // сравнить двух студентов
  71.         //boolean result = s > s2;                
  72. //        int i = 10;
  73. //        System.out.println("i=" + i);
  74. //        boolean result = i > 1;
  75. //        System.out.println("result=" + result);
  76.     }
  77. }
  78.  
Add Comment
Please, Sign In to add comment