Advertisement
Gologo

stakan

Mar 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1.  
  2. public class Stakan {
  3.      
  4.     private  float m;
  5.     private  float v;
  6.     private  float content;
  7.    
  8.         public
  9.     Stakan(){
  10.         m = 30;
  11.         v = 200;
  12.         content = 0;
  13.     };
  14.        
  15.     public
  16.     Stakan(float m,float v,float c){
  17.         this.m = m;
  18.         this.v = v;
  19.         content = c;
  20.     };
  21.    
  22.     float getMass(){
  23.         return m;
  24.     }
  25.    
  26.        
  27.     float getVolume(){
  28.         return v;
  29.     }
  30.    
  31.     float getContent(){
  32.         return content;
  33.     }
  34.    
  35.     boolean setMass(float m){
  36.         this.m = m;
  37.        
  38.         if(m == getMass()){
  39.         return true;
  40.         }else{
  41.             return false;
  42.         }
  43.     }
  44.    
  45.     boolean setVolume(float v){
  46.         this.v = v;
  47.         if(v == getVolume()){
  48.         return true;
  49.         }else{
  50.             return false;
  51.         }
  52.        
  53.     }
  54.    
  55.     boolean setContent(float C){
  56.         content = C;
  57.         if(C == getContent()){
  58.         return true;
  59.         }else{
  60.             return false;
  61.         }
  62.        
  63.     }
  64.    
  65.     void print(){
  66.                 System.out.println();
  67.         System.out.print("Масса = " + getMass() + " g, ");
  68.         System.out.print("Объем = " + getVolume() + " ml, ");
  69.         System.out.print("Содержание = " + getContent() + " ml, ");
  70.                 System.out.println();
  71.     }
  72.  
  73.    
  74.    
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement