package java0829_class; /* * ìë를 참조íì¬ main() ë©ìë를 ì¶ê°íë ë¡ì§ì 구ííì¸ì. * * [ì¤íê²°ê³¼] ìí ê°ê²© ìíì ê³ í린ìë Nikon 400000 30 50 Sony 450000 20 35 FujiFilm 350000 10 25 */ class Goods { String name; // ìíëª int price; // ìí ê°ê²© int numberOfStock; // ìí ì¬ê³ int sold; // í린 ìë public Goods() { } public Goods(String name, int price, int numberOfStock, int sold) { this.name = name; this.price = price; this.numberOfStock = numberOfStock; this.sold = sold; } public void prn() { System.out.printf("%-14s %8d %5d %5d \n", name, price, numberOfStock, sold); } } public class Java074_class { public static void display(Goods[] goodArray) { for (int i = 0; i < goodArray.length; i++) { goodArray[i].prn(); } } public static void main(String[] args) { /* Goods nc = new Goods("Nikon", 400000, 30, 50); Goods sc = new Goods("Sony", 450000, 20, 35); Goods fc = new Goods("FujiFilm", 350000, 10, 25); System.out.printf("%-14s\t%4s %8s %5s \n", "ìí", "ê°ê²©", "ìí ì¬ê³ ", "í린 ìë"); nc.prn(); sc.prn(); fc.prn(); */ Goods[] goodArray = new Goods[3]; goodArray[0] = new Goods("Nikon", 400000, 30, 50); goodArray[1] = new Goods("Sony", 450000, 20, 35); goodArray[2] = new Goods("FujiFilm", 350000, 10, 25); /* goodArray[0].prn(); goodArray[1].prn(); goodArray[2].prn(); */ /* for (int i = 0; i < goodArray.length; i++) { goodArray[i].prn(); } */ display(goodArray); } }