Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package day3_classes;
- /**
- *
- * @author sao_7
- */
- public class tasks {
- private int a; //uztaisam lauku, a - lauks
- public tasks(){
- a = 0;
- }
- public void setA(int number){
- //ja number vertiba ir no 5-15, tad viss ir ok
- //ja ne tad pieskiram 99
- a = number;
- if (number < 5 || number > 15) {
- a = 99;
- }
- }
- public void printA(){
- System.out.println(a);
- }
- public static void pyramid(){
- //*
- //**
- //***
- //****
- //***
- //**
- //*
- //ar ciklu for:
- for(int i = 0; i < 4; i++){
- for (int j = 0; j <= i; j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- for(int i = 2; i >= 0; i--){
- for (int j = 0; j <= i; j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- //tas pats ar masiivu
- public static void pyramid2(){
- //String[] stars = new String[4]; - pirmaa iespeeja
- //otraa iespeeja:
- String[] stars = {"*", "**", "***", "****"};
- for (int i = 0; i < 4; i++) {
- System.out.println(stars[i]);
- }
- for (int i = 2; i >= 0; i--) {
- System.out.println(stars[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement