1. Dog1.java – Class to be used when generating instances DogTest1.java – Class to create and print instances through Dog1 (object generation using ArrayList)
output screen
* Dog1 class // default generator (if not generated during generator overload), which receives and stores puppy names and dog types. Since the public Dog1(){};// member variable is declared private, a method to extract and deliver values through getter must be created.getter & setters // String形式の値を返すshowDogInfo() メソッドpublic String showDogInfo() {return name + “, ” +type; }Dog1.java Class
package test;public クラス Dog1 {private String name;private String type;public Dog1() {this.name = name;this.type = type;}//강아지 이름과 견종을 문자열로 리턴public String showDogInfo() {return name +,” ” + type;}//getter & setter 생략}
package test;public クラス Dog1 {private String name;private String type;public Dog1() {this.name = name;this.type = type;}//강아지 이름과 견종을 문자열로 리턴public String showDogInfo() {return name +,” ” + type;}//getter & setter 생략}
Dog1 showDogInfo() Method
// The basic form of the first contact for statement // The size of the array in the dogList is access via size ////// access to each index value via get(i);i++){System.out.println(dogList.get(i).showDogInfo()); }DogTest1.java 클래스
// The basic form of the first contact for statement // The size of the array in the dogList is access via size ////// access to each index value via get(i);i++){System.out.println(dogList.get(i).showDogInfo()); }DogTest1.java 클래스
Import package test;java.fil.ArrayList;public class DogTest1 {public static void main(String[] args) {//ArrayaList 객체 생성 rrayList<Dog1> dogList = new ArrayList<>();//Dog1 클래스를 사용하여 dog1 dog= new Dog1();//디폴트 생성자 선언하지 않으면 오류가 나게 됨/dogList.add(d);에러”말티즈.”돌돌이.”객체 배열에 데이터를 추가.”웰시코기.addドッグリストを追加します.add(new Dog1(“콩떡이”, 포메라니안”);ogList.add(new Dog1(“감자”, 볼로네즈”);ogList.add(new Dog1(“인절미”, 치와와 “));//향상된 for(Dog1s : dogList) {system.out.println(s.showDogInfo)}system.out.println ( “)So, it’s a thing—————————————————————-“;// “;// 기존에 배웠던 for(inti=0;i<dogList.size();i++) {system.out.println(dogList.get(i))) 문으로 응용하기 です.showDogInfo();.}
2. Worker2.java – Employee number, employee name, position, department, annual salary, and bonus class WorkerTest2.java – Main class that generates and outputs instances using Worker2 classoutput screenoutput screenoutput screen//Worker2 p1= Worker 2(” and “”, to generate objects from the end of the creation of objects from the generation of the generation of the generation of the generation of the generation of = If the networker 2(” and the parameter value of the set forth in the format of the format and the parameter value of the format and parameter value.Server2 p1= Worker 2()//set method.pp1.set~(“~”);//Worker2The show Info() method 3 calls that the show Info() method is automatically calculated through the method of the .// bonus value is automatically calculated through the method.pp1.mbshowInfo();WorkerTest2.java Classpackage test;public class WorkerTest2 {public static void main(String[] args) {//Worker2 클래스를 사용하여 인스턴스 생성 orker2 pp1 = new Worker2();//생성자 오버로딩 후 p1//Worker2pp1=new Worker2(“A001″,”대리”,”총무부”,”400000);//setter를 통해서 값 입력하기.SetMbID(“홍길동);p1.SetMbName(총무부.Set);P.대리Mb.Steam.S。setMbSalary(40000000);p1.mbshowInfo();}}package test;public class WorkerTest2 {public static void main(String[] args) {//Worker2 클래스를 사용하여 인스턴스 생성 orker2 pp1 = new Worker2();//생성자 오버로딩 후 p1//Worker2pp1=new Worker2(“A001″,”대리”,”총무부”,”400000);//setter를 통해서 값 입력하기.SetMbID(“홍길동);p1.SetMbName(총무부.Set);P.대리Mb.Steam.S。setMbSalary(40000000);p1.mbshowInfo();}}3. Ticket3.java – a class that receives audience information and generates objects (name, age, seat, location), and method-generated TicketTest3.java – a class that generates an instance (object) by entering audience information and outputs audience informationoutput screen//Decimal Format forr = new Decimal Format(“##,##”);// Method of determining if the age value of the audience information is the age at which the audience can view the price information. {/ Method of pricing according to the seat value of the audience information//Decimal Format forr = new Decimal Format(“##,##”);// Method of determining if the age value of the audience information is the age at which the audience can view the price information. {/ Method of pricing according to the seat value of the audience informationCreated a pp1 object (instance) using the Ticket3 class.It is a class that inputs audience information (using generator overloading) at the same time as instance generation and outputs audience information to the console using the corresponding value.TicketTest3.java Classpackage test;public class TicketTest3 {public static void main(String[] args) {icket3pp1 = new Ticket3(“홍길동”, 23, “S석”, “더현대서울”);p1.ticketshowInfo();}}package test;public class TicketTest3 {public static void main(String[] args) {icket3pp1 = new Ticket3(“홍길동”, 23, “S석”, “더현대서울”);p1.ticketshowInfo();}}package test;public class TicketTest3 {public static void main(String[] args) {icket3pp1 = new Ticket3(“홍길동”, 23, “S석”, “더현대서울”);p1.ticketshowInfo();}}