Facebook
From Soft Shama, 3 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 74
  1. /**
  2.  * Actor.java defineste un actor.
  3.  * @autor Markus
  4.  * @version 1.0
  5.  * @since 10/05/2020
  6.  */
  7. public class Actor {
  8.     private String firstName;
  9.     private String lastName;
  10.     int year;
  11.     public String schoolName = "Fara scoala";
  12.  
  13.     /**
  14.      * Constructor explicit al clasei autor.
  15.      * @param firstName String
  16.      * @param lastName  String
  17.      * @param year  int
  18.      * @param schoolName String
  19.      */
  20.     public Actor(String firstName, String lastName, int year, String schoolName){
  21.         this.firstName = firstName;
  22.         this.lastName = lastName;
  23.         this.year = year;
  24.         this.schoolName = schoolName;
  25.     }
  26.  
  27.     public Actor(){
  28.         this.lastName = null;
  29.         this.firstName = null;
  30.         this.year = 0;
  31.         this.schoolName = null;
  32.     }
  33.  
  34.     public Actor(Actor a){
  35.         this.firstName = a.firstName;
  36.         this.lastName = a.lastName;
  37.         this.year = a.year;
  38.         this.schoolName = a.schoolName;
  39.     }
  40.  
  41.     public Actor(String firstName, String lastName, int year){
  42.         this.firstName = firstName;
  43.         this.lastName = lastName;
  44.         this.year = year;
  45.     }
  46.  
  47.     public String toString() {
  48.         return "Nume: " + this.firstName + " Prenume: " + this.lastName + " An: " + this.year + " Scoala: " + this.schoolName;
  49.     }
  50.  
  51.     /**
  52.      * Returneaza prenumele.
  53.      * @return firstName String
  54.      */
  55.     public String getFirstName(){
  56.         return firstName;
  57.     }
  58.  
  59.     /**
  60.      * Seteaza prenumele
  61.      * @param firstName String
  62.      */
  63.     public void setFirstName(String firstName) {
  64.         this.firstName = firstName;
  65.     }
  66.  
  67.     public String getLastName(){
  68.         return lastName;
  69.     }
  70.  
  71.     public void setLastName(String lastName) {
  72.         this.lastName = lastName;
  73.     }
  74.  
  75.     public String getSchoolName(){ return schoolName;}
  76.  
  77. }
  78.  
  79. /**
  80.  * Main.java implementeaza Actor
  81.  * @see Actor
  82.  */
  83.  
  84. public class Main {
  85.     public static void main(String[] args) {
  86.         Actor a = new Actor("Gi","Enescu",123,"UVT");
  87.         Actor a1 = new Actor();
  88.         a1 = a;
  89.         System.out.println("Primul a: " + a);
  90.         System.out.println("Al doilea a: " + a1);
  91.         System.out.println("Primul a: " + a);
  92.         System.out.println("Al doilea a: " + a1);
  93.         Actor[] listaActori = new Actor[5];
  94.         listaActori[0] = a;
  95.         listaActori[1] = new Actor("Alex","Dumitrescu",4);
  96.         listaActori[2] = new Actor("Silviu", "Nan",54,"timisoara");
  97.         listaActori[3] = new Actor("Giulia","Andreea",23);
  98.  
  99.         int counter = 0;
  100.         for(Actor i:listaActori){
  101.             if(i != null) {
  102.                 if (i.getSchoolName().equals("Fara scoala"))
  103.                     counter += 1;
  104.             }
  105.         }
  106.         System.out.println("Numarul de actori fara scoala de actorie: " + counter);
  107.  
  108.         for(Actor i:listaActori){
  109.             if(i != null){
  110.                 String s = i.getFirstName().toLowerCase();
  111.                 if(s.equals(args[0])|| s.startsWith(args[0]))
  112.                     System.out.println(i.getFirstName());
  113.             }
  114.         }
  115.     }
  116. }

Replies to Untitled rss

Title Name Language When
Lab2Problema1 Colorant Bird java 3 Years ago.