SHARE
TWEET

java - Day3_Classes.tasks

Svetlana_Ovsjanikova Sep 21st, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 day3_classes;
  7.  
  8. /**
  9.  *
  10.  * @author sao_7
  11.  */
  12. public class tasks {
  13.    
  14.     private int a; //uztaisam lauku, a - lauks
  15.    
  16.     public tasks(){
  17.         a = 0;
  18.     }
  19.    
  20.     public void setA(int number){
  21.         //ja number vertiba ir no 5-15, tad viss ir ok
  22.         //ja ne tad pieskiram 99
  23.         a = number;
  24.         if (number < 5 || number > 15) {
  25.             a = 99;
  26.         }
  27.     }
  28.    
  29.     public void printA(){
  30.         System.out.println(a);
  31.     }
  32.     public static void pyramid(){
  33.     //*
  34.     //**
  35.     //***
  36.     //****
  37.     //***
  38.     //**
  39.     //*
  40.    
  41.         //ar ciklu for:
  42.         for(int i = 0; i < 4; i++){
  43.             for (int j = 0; j <= i; j++) {
  44.                 System.out.print("*");
  45.             }
  46.            
  47.             System.out.println();
  48.         }
  49.        
  50.         for(int i = 2; i >= 0; i--){
  51.             for (int j = 0; j <= i; j++) {
  52.                 System.out.print("*");
  53.             }
  54.            
  55.             System.out.println();
  56.         }
  57.     }
  58.     //tas pats ar masiivu
  59.     public static void pyramid2(){
  60.         //String[] stars = new String[4]; - pirmaa iespeeja
  61.         //otraa iespeeja:
  62.         String[] stars = {"*", "**", "***", "****"};
  63.        
  64.         for (int i = 0; i < 4; i++) {
  65.             System.out.println(stars[i]);
  66.         }
  67.         for (int i = 2; i >= 0; i--) {
  68.             System.out.println(stars[i]);  
  69.         }
  70.     }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top