You are right, and I know it. If I am ever to be self sufficient I must learn the APIs. This is not something that was covered before class, not something covered during class, we are just kind of told they are there if we need them during the first week, and left to discover them on our own. I do not really have a problem with that, but when thrown neck deep in coding assignments trying to figure them out just confuses me more. I graduate in two more weeks, and at that time I plan to actually begin learning all these things that will actaully make me a better programmer.
Immediate problem for me is my grade, so long term has to be set aside for now, as frustrating as it may be.
I did go through the tutorial on formatting, and it was pretty helpful in some respects.
I am trying this:
import java.util.*;
public class CdwArtist extends Compactdisk
{
private String artist; // artist performing on cd
private float restock; // restocking percentage
private float total; // total of all inventory stock
// Artist constructor
public CdwArtist()
{
artist = "";
restock = .05f;
total = .00f;
}
public CdwArtist(String in)
{
artist=in;
}
// get values
public void setArtist(String in)
{
artist=in;
}
public void setRestock(float cdRestock)
{
restock = cdRestock;
}
public void setTotal(float cdtotal)
{
total = cdtotal;
}
// return value
public String getArtist()
{
return (artist);
}
// returns indivudual inventory value for a disk
public float getTotal()
{
return(price * nstock)+((price * nstock)* restock);
}
static public void customFormat(String pattern, float value, float price, float total )
{
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(value);
System.out.println(value + " " + pattern + " " + output);
}
//new toString
public String toString()
{
return "Artist: " + artist +
" CD Name: " + name +
" Item Number: " + itemno +
" Price: $" +price +
" In Stock: " + nstock +
" Stock Value: $" + getValue() +
" Restocking Fee: $" + restock +
" Total Inventory Value: $" + getTotal();
}
} //End Class
and it compiles, but I do not think "pattern" and "value" are literal are they? Should I not have ###.## for my pattern, and 0.00 for my value?
They error out when I do that of course, so I know it is wrong, and I think I understand what I have written, should take a parameter and put it in a certain pattern and value, but now the tutorial starts losing me as to exactly what pattern and value are, and how to apply them to what I have here. I would not think I would have an output line in there at all, but like I said, I start getting really confused at this point.