자바 배열 저장후 출력 질문이요
계획자
지금 입력까지는 되는데 (2)상품조회 하는부분을 못하구있어요
입력받은걸 저장했다가 출력하는 방법을 잘모르겠어요...
소스 수정부탁드립니다
배열이 아니라도 입력받은걸 조회해서 출력 할 수있게 해주세요
import java.util.Scanner;
class Product {
String proID;
String desc; //상품설명
String maker; //생상자
int price; //가격
void proinfo(){
Scanner scan = new Scanner(System.in);
System.out.printf(상품ID);
proID=scan.nextLine();
System.out.printf(상품설명);
desc=scan.nextLine();
System.out.print(생산자);
maker = scan.nextLine();
System.out.print(가격);
int price = scan.nextInt();
scan.nextLine();
}
void proshow() {
System.out.println(상품D+proID);
System.out.println(상품설명+desc);
System.out.println(생산자+maker);
System.out.println(가격+price);
}
}
class Book extends Product {
String ISBN; //ISBN
String title; //책제목
String author; //저자
void bookinfo() {
Scanner scan = new Scanner(System.in);
proinfo();
System.out.print(ISBN);
ISBN = scan.nextLine();
System.out.print(책제목);
title = scan.nextLine();
System.out.print(저자);
author= scan.nextLine();
}
void bookshow() {
proshow();
System.out.println(ISBN+ISBN);
System.out.println(책제목+title);
System.out.println(저자+author);
}
}
class ConversationBook extends Book{
String language;
void coninfo(){
Scanner scan = new Scanner(System.in);
super.bookinfo();
System.out.print(언어);
language = scan.nextLine();
}
void conshow() {
super.bookshow();
System.out.println(언어+language);
}
}
class CompactDisc extends Product {
String albumtitle; //앨범제목
String artist; //가수
void albuminfo(){
Scanner scan = new Scanner(System.in);
proinfo();
System.out.print(앨범제목);
albumtitle=scan.nextLine();
System.out.print(가수);
artist=scan.nextLine();
}
void albumshow() {
proshow();
System.out.println(앨법제목+albumtitle);
System.out.println(가수+artist);
}
}
public class y{
public static void main(String[] args) {
int proID = 0;
int numberOfProduct = 0;
Product[] p = new Product[10];Book book = new Book();
ConversationBook con = new ConversationBook();
CompactDisc com = new CompactDisc();Scanner scan = new Scanner(System.in);
int choice=0;
int type;
while(choice != 3) {
System.out.print(상품추가(1), 모든상품조회(2), 끝내기(3));
choice = scan.nextInt();
switch (choice) {
case 1: //상품추가
System.out.print(상품종류책(1), 음악D(2), 회화책(3));
type = scan.nextInt();
switch(type) {
case 1:
book.bookinfo();
break;
case 2:
com.albuminfo();
break;
case 3:
con.coninfo();
break;
}
break;
case 2: //모든상품조회
{
book.bookshow();
com.albumshow();
con.conshow();
}
break;
case 3: //끝내기
break;
}
}
}
}