// 도표 참조 or Customer 클래스 코드 작성 public class TestCustomer { public static void main(String[] args) { // TODO Auto-generated method stub Customer customer = new Customer(1, "HGD", 1000); System.out.println(customer); // customer toString() customer.setDiscount(5000); // setter() // getter() System.out.println("Customer ID >> " + customer.getID()); System.out.println("Customer Name >> " + customer.getName()); System.out.println("Customer Discount >> " + customer.getDiscount()); Invoice invoice = new Invoice(101, customer, 0.1); System.out.println(invoice); // invoice toString() System.out.println("Invoice ID >> " + invoice.getID()); System.out.println("Invoice customer toStirng >> " + invoice.getCustomer().toString()); System.out.println("Invoice customer getID >> " + invoice.getCustomer().getID()); System.out.println("Invoice amount >> " + invoice.getAmount()); System.out.println("Invoice getCustomerName >> " + invoice.getCustomerName()); System.out.println("할인 된 금액(getAcountAfterDiscount()) >> " + invoice.getAmountAfterDiscount()); } } public class Customer { // 오류발생 private int ID; private String name; private int discount; public Customer() {} public Customer(int ID, String name, int discount) { this.ID = ID; this.name = name; this.discount = discount; } public int getID() { return ID; } public String getName() { return name; } public int getDiscount() { return discount; } public void setDiscount(int discount) { this.discount = discount; } @Override public String toString() { return "Customer [ID=" + ID + ", name=" + name + ", discount=" + discount + "]"; } } public class Invoice { // 오류발생 private int ID; private Customer customer; private double amount; public Invoice() {} public Invoice(int ID, Customer customer, double amount) { this.ID = ID; this.customer = customer; this.amount = amount; } public int getID() { return ID; } public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public double getAmount() { return amount; } public void setAmount(double amount) { this.amount = amount; } public String getCustomerName() { return customer.getName(); } // 할인 후 금액 가져오기 public double getAmountAfterDiscount() { return customer.getDiscount()-(customer.getDiscount() * amount); } } ~~~첫 번째 코드~~~ // 클래스 Book의 모든 공용 메서드를 테스트 하는 드라이버 TestBook 작성 public class TestBook { public static void main(String[] args) { // TODO Auto-generated method stub // 전자 인스턴스 생성 Author ahTeck = new Author("Tan Ah Teck", "[email protected]", 'm'); System.out.println("Author toString >> " + ahTeck); // Author의 toString() Book dummyBook = new Book("java for dummy", ahTeck, 19.95, 99); System.out.println("Book toString >> " + dummyBook); dummyBook.setPrice(29.95); // Book의 생성자 Test dummyBook.setQty(28); // Book toString() Test // Getter와 Setter Test System.out.println("name >> " + dummyBook.getName()); System.out.println("price >> " + dummyBook.getPrice()); System.out.println("qty >> " + dummyBook.getQty()); System.out.println("Author >> " + dummyBook.getAuthor()); // Author의 toString() System.out.println("Author's name >> " + dummyBook.getAuthor().getName()); System.out.println("Author's email >> " + dummyBook.getAuthor().getEmail()); // Book 인스턴스 생성을 위해 무명 Author 인스턴스 사용 Book anotherBook = new Book("more Java", new Author("Paul Tan", "[email protected]", 'm'), 29.95); System.out.println(anotherBook); // toString() } } public class Book { // 오류발생 private String name; private Author author; private double price; private int qty; public Book() {} public Book(String name, Author author, double price) { this.name = name; this.author = author; this.price = price; } public Book(String name, Author author, double price, int qty) { this.name = name; this.author = author; this.price = price; this.qty = qty; } public String getName() { return name; } public Author getAuthor() { return author; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public int getQty() { return qty; } public void setQty(int qty) { this.qty = qty; } @Override public String toString() { return "Book [name=" + name + ", author=" + author + ", price=" + price + ", qty=" + qty + "]"; } } ~~~두 번째 코드~~~ // Author 클래스 프로그램 작성 public class TestAuthor { public static void main(String[] args) { // TODO Auto-generated method stub Author ahTeck = new Author("Tan Ah Teck", "[email protected]", 'm'); System.out.println(ahTeck); ahTeck.setEmail("[email protected]"); //Test setter System.out.println("name : " + ahTeck.getName()); //Test getter System.out.println("email : " + ahTeck.getEmail()); //Test getter System.out.println("gender : " + ahTeck.getGender()); // Test getter } } public class Author { // 오류발생 private String name; private String email; private char gender; public Author() {} public Author(String name, String email, char gender) { this.name = name; this.email = email; this.gender = gender; } public String getName() { return name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public char getGender() { return gender; } @Override public String toString() { return "Author [name=" + name + ", email=" + email + ", gender=" + gender + "]"; } } 비슷한 곳에서 오류가 나는데 왜 그런거에요,,? 답답해 죽을거같아용 ㅠㅠ 또 뭔가 위치가 잘못 된걸까요??
오류 내용을 올려주셔유
주석으로 오류발생이라고 달아놨어요ㅇ0ㅇ Multiple markers at this line - Debug Current Instruction Pointer - The public type Author must be defined in its own file 이런식으로 오류 메세지?? 나오고,,