/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test1exp; import java.util.Scanner; /** * * @author jcmt */ public class NotesFolder { private double height; private double width; private boolean pockets; private int fasteners; private Material madeOf; private String madeOfWord; public NotesFolder() { this.height = 10.0; this.width = 10.0; this.pockets = false; this.fasteners = 0; this.madeOf = Material.PAPER; this.madeOfWord = toMadeOfWord(madeOf); } public NotesFolder(double height, double width, boolean pockets, int fasteners, Material madeOf) { this.height = height; this.width = width; this.pockets = pockets; this.fasteners = fasteners; this.madeOf = madeOf; this.madeOfWord = toMadeOfWord(madeOf); } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } public double getWidth() { return width; } public void setWidth(double width) { this.width = width; } public boolean isPockets() { return pockets; } public void setPockets(boolean pockets) { this.pockets = pockets; } public int getFasteners() { return fasteners; } public void setFasteners(int fasteners) { this.fasteners = fasteners; } public Material getMadeOf() { return madeOf; } public void setMadeOf(String sMadeOf) { //this.madeOf = madeOf; madeOf = materialFinder(sMadeOf); this.madeOfWord = toMadeOfWord(madeOf); } public void setMadeOf(Material madeOf) { this.madeOf = madeOf; this.madeOfWord = toMadeOfWord(madeOf); } private Material materialFinder(String im) { int ic =0; if (im.equalsIgnoreCase("P")) { ic = 1; } else if (im.equalsIgnoreCase("C")) { ic = 2; } else if (im.equalsIgnoreCase("O")) { ic = 3; } else if (im.equalsIgnoreCase("G")) { ic = 4; } switch (ic) { case 1: return Material.PAPER; case 2: return Material.CARDBOARD; case 3: return Material.POLY; case 4: return Material.GLOSSY_STOCK; default: return Material.MISC; } } private String toMadeOfWord(Material im) { String ic = "miscellaneous"; if (im == Material.PAPER) { ic = "paper"; } else if (im == Material.CARDBOARD) { ic = "cardboard"; } else if (im == Material.POLY) { ic = "poly"; } else if (im == Material.GLOSSY_STOCK) { ic = "glossy or printed cardstock"; } return ic; } public String toString() { String msg = new String(); msg = msg + "This folder of size " + width + " by "+ height; if (pockets) { msg = msg + " with pockets "; } if ((pockets) && (fasteners > 0)) { msg = msg + " and "; } if (fasteners > 0) { msg = msg +" with "+ fasteners +" fasteners "; } msg = msg +" is made out of "+ toMadeOfWord(madeOf); return msg; } }