Advertisement
JanBarhoum

Untitled

Nov 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.28 KB | None | 0 0
  1.  
  2. public class Malbin {
  3.  
  4.     //Create Constractor with Length And Width !
  5.    
  6.     private double length,width;
  7.  
  8. // GETTERS and SETTERS !
  9.    
  10.     public double getLength() {
  11.         return length;
  12.     }
  13.  
  14.  
  15.     public void setLength(double length) {
  16.         this.length = length;
  17.     }
  18.  
  19.  
  20.     public double getWidth() {
  21.         return width;
  22.     }
  23.  
  24.  
  25.     public void setWidth(double width) {
  26.         this.width = width;
  27.     }
  28.    
  29.      public Malbin(double length, double width) {
  30.             this.length = length;
  31.             this.width = width;
  32.         }
  33.  
  34. // Constractor that takes 10,10 !
  35.     public Malbin() {
  36.         this(10, 10);
  37.     }
  38.  
  39. // Calculate the sides of the malbin 2*length + 2*width !
  40.    
  41.       public void Sides() {
  42.             double sidesLength = 2 * (length) + 2 * (width);
  43.             System.out.printf("The Malbin sideS length is: " + sidesLength);
  44.         }
  45.    
  46.     //Calculate malbin surface = length * width = surface !
  47.    
  48.        public void malbinSurface() {
  49.             double size = length * width;
  50.             System.out.print("Malbin Scale  size is: " + size);
  51.         }
  52.        
  53.        // print malbin with "*"  ****
  54.        //                        ****
  55.        //                        ****
  56.        
  57.        
  58.        
  59.        
  60.        public void print() {
  61.             for (int mLength = 0; mLength < length; mLength++) {
  62.                 for (int mWidth = 0; mWidth < width; mWidth++) {
  63.                     System.out.print("*");
  64.                 }
  65.                 System.out.println();
  66.             }
  67.         }
  68.        
  69.        
  70.        
  71.        // print malbin the same thing but with Character !
  72.        
  73.        
  74.        public void print2(char character) {
  75.             for (int mLength = 0; mLength < length; mLength++) {
  76.                 for (int mWidth = 0; mWidth < width; mWidth++) {
  77.                     System.out.print(character);
  78.                 }
  79.                 System.out.println();
  80.             }
  81.         }
  82.      
  83.     }
  84.        
  85.      
  86.        
  87.    
  88. ***************************************************************************************************************************************
  89.  
  90.  
  91.  
  92.  
  93. public class MalbinTester {
  94.  
  95.     public static void main(String[] args) {
  96.        
  97.         // send to functions and Printing !
  98.        
  99.         Malbin m1 = new Malbin();
  100.        
  101.         m1.Sides();
  102.         System.out.println();
  103.        
  104.         m1.malbinSurface();
  105.         System.out.println();
  106.        
  107.         m1.print();
  108.         System.out.println();
  109.        
  110.        
  111.         m1.print2('x');
  112.        
  113.        
  114.        
  115.        
  116.     }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement