RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting

First JLIST, used with GUI Inventory

Join Date: Jul 2007
Posts: 186
Reputation: no1zson is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
no1zson's Avatar
no1zson no1zson is offline Offline
Junior Poster

Re: First JLIST, used with GUI Inventory

  #47  
Jul 27th, 2007
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.
I never drew first, but I drew first blood.
I'm no ones son, unforgiven.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:22 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC