HarrJ

Day09B

Sep 24th, 2023 (edited)
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. public class Day09B {
  2.     public static void main(String[] args) {
  3.         //testing multiple class is one file
  4.         PrintWords callPrint = new PrintWords();
  5.         callPrint.printHello();
  6.         callPrint.callText1();
  7.         callPrint.txt1 = "I am changed here at Day09B";
  8.         callPrint.callText1();
  9.         callPrint.useActionWord("running");
  10.     }
  11. }
  12. // only one public class
  13. class PrintWords {
  14.     public String txt1 = "MNG B8";
  15.  
  16.     void printHello() {
  17.         System.out.println("Welcome to Jurassic Park");
  18.     }
  19.  
  20.     void callText1(){
  21.         System.out.println("text 1 value: " + txt1);
  22.     }
  23.  
  24.     void useActionWord(String verb) {
  25.         System.out.println("The cat is " + verb);
  26.     }
  27. }
  28.  
  29. //----DIFFERENT FILE-------------------------------------------------
  30.  
  31. package week2;
  32.  
  33. public class Day09C {
  34.     public static void main(String[] args) {
  35.         D9MoreSamples callSample01 = new D9MoreSamples();
  36.         D9MoreSamples callSample02 = new D9MoreSamples();
  37.         D9MoreSamples callSample03 = new D9MoreSamples();
  38.         //to edit an static variable:
  39.         D9MoreSamples.section = "JAVA-B5-2023";
  40.  
  41.         callSample01.printProfile();
  42.  
  43.         callSample02.name = "Gelai";
  44.         callSample02.addr = "Bagumbayan Street, Iloilo city, 5700 Antique";
  45.         callSample02.printProfile();
  46.  
  47.         callSample03.name = "Blooms";
  48.         callSample03.addr = "Hamtic Pob. 5 Antique";
  49.         callSample03.printProfile();
  50.     }
  51. }
  52.  
  53. class D9MoreSamples {
  54.     String name="Juan dela Cruz";
  55.     String addr="San Jose, Antique";
  56.     static String section = "Java B8 2023";
  57.  
  58.     void printProfile() {
  59.         System.out.println("He/She is " + name + " from " + addr
  60.             + " and is a trainee of MNG TVI on the section of " + section);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment