nid help when displaying added items in my program
i've been working with this 2 days now and i cant make it to run properly
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Gasendo
*/
public class Book{
private String bookTitle;
private int bookYear;
public String getBookTitle() {
return bookTitle;
}
public void setBookTitle(String bookTitle) {
this.bookTitle = bookTitle;
}
public int getBookYear() {
return bookYear;
}
public void setBookYear(int bookYear) {
this.bookYear = bookYear;
}
public String toString(){
String output = "";
output = "" + this.getBookTitle();
output += ", " + this.getBookYear();
return output;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
/**
*
* @author Gasendo
*/
public class Accessory{
private String accName;
private String accColor;
private double price;
public String getAccColor() {
return accColor;
}
public void setAccColor(String accColor) {
this.accColor = accColor;
}
public String getAccName() {
return accName;
}
public void setAccName(String accName) {
this.accName = accName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String toString(){
String output = "";
output = "" + this.getAccName();
output += "\n" + this.getAccColor();
output += "\n" +this.getPrice();
return output;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Gasendo
*/
public class Apparel {
private String appName;
private String appColor;
public String getAppColor() {
return appColor;
}
public void setAppColor(String appColor) {
this.appColor = appColor;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String toString(){
String output = "";
output = "" + this.getAppName();
output += ", " + this.getAppColor();
return output;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
/**
*
* @author Gasendo
*/
public class Cabinet{
public static void main(String[]args){
Scanner mike = new Scanner(System.in);
boolean done = false;
while(!done){
System.out.println("Please choose an option from the given menu below. Just type the number. ");
System.out.println("[1] Add Book\n[2] Add Apparel\n[3] Add Accessory\n[4] Display Books\n[5] Display Apparel\n[6] Display Accessory\n[7] Exit");
System.out.print("What do you want to do? ");
int m = mike.nextInt();
if(m==1){
Book book = new Book();
System.out.println("You choose to add a book.");
System.out.print("Book name/title: ");
String title = mike.next();
book.setBookTitle(title);
System.out.print("Publication Year: ");
int year = mike.nextInt();
book.setBookYear(year);
System.out.println("Book added successfully! ");
}
if (m==2){
Apparel apparel = new Apparel();
System.out.println("You choose to add apparel.");
System.out.print("Apparel Name: ");
String appname = mike.next();
apparel.setAppName(appname);
System.out.print("Color: ");
String appcolor = mike.next();
apparel.setAppColor(appcolor);
System.out.println("Apparel added successfully! ");
}
if (m==3){
Accessory accessory = new Accessory();
System.out.println("You choose to add accessory.");
System.out.print("Acessory Name: ");
String accname = mike.next();
accessory.setAccName(accname);
System.out.print("Color: ");
String acccolor = mike.next();
accessory.setAccColor(acccolor);
System.out.print("Price: ");
double price = mike.nextDouble();
accessory.setPrice(price);
System.out.println("Accessory added successfully! ");
}
if(m==7){
System.exit(0);
}
}
}
}
my desired output is this:
PHP Code:
Please choose an option from the given menu below. Just type the number.
[1] Add Book
[2] Add Apparel
[3] Add Accessory
[4] Display Books
[5] Display Apparel
[6] Display Accessory
[7] Exit
What do you want to do? 1
You choose to add a book.
Book name/title : Java Book
Publication Year: 2009
Book added successfully!
Please choose an option from the given menu below. Just type the number.
[1] Add Book
[2] Add Apparel
[3] Add Accessory
[4] Display Books
[5] Display Apparel
[6] Display Accessory
[7] Exit
What do you want to do? 2
You choose to add apparel.
Apparel Name: Pants
Color : Blue
Apparel added successfully!
Please choose an option from the given menu below. Just type the number.
[1] Add Book
[2] Add Apparel
[3] Add Accessory
[4] Display Books
[5] Display Apparel
[6] Display Accessory
[7] Exit
What do you want to do? 3
You choose to add accessory.
Accessory Name: Earring
Color : Silver
Price : 5000.00
Accessory added successfully!
a little hint will do buddies.