I have all my code done, but it keeps saying no suitable constructor found (close to the bottom on the first code- ProduceInfo pInfo section- line 150) and cannot find symbol (line 62). I have read over this code, searched the errors on the net, and watched videos to try and figure it out. I would appreciate any help. Thank you in advance.
package farmersmarket3;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Locale;
public class FarmersMarket3 {
// creates item array
static ProduceInfo[] produceItem = new ProduceInfo[0];
/**
* @param args the command line arguments
*/
static int presentItem = 0;
public static void main(String[] args) {
addProduceItem("Gene's Greenhouse", "Apples", 56987543, 36, 13.75);
addProduceItem("Sue's One Stop", "Corn", 01120124, 64, 19.60);
addProduceItem("Big Bills", "Strawberries", 22539874, 19, 26.99);
addProduceItem("All Produce", "Tomatoes", 87765801, 53, 10.01);
addProduceItem("Smith's", "Potatoes", 45663336, 42, 21.00);
addProduceItem("Diggin's Farm", "Watermelon", 52000251, 81, 6.77);
itemsSort();
ProduceGUI prodGUI = new ProduceGUI();
}
public static double itemCost() {
double cost = 0;
for(int y = 0; y < produceItem.length; y++)
{
cost += produceItem[y].getTotal();
}
return cost;
}
public static void itemsSort() {
ProduceInfo temporary;
for (int presentItem = 0; presentItem < produceItem.length; presentItem++);
{
for (int i = presentItem + 1; i < produceItem.length; i++){
String item0 = produceItem[presentItem].getItem();
String item1 = produceItem[i].getItem();
if (item0.compareTo(item1) > 0) {
temporary = produceItem[presentItem];
produceItem[presentItem] = produceItem[i];
produceItem[i] = temporary;
}
}
}
}
public static String getPresentTotalString() {
if (produceItem.length == 0) {
return "No items:";
}
else {
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter (sb, Locale.US);
formatter.format(produceItem[presentItem].toString());
formatter.format("\n");
formatter.format("Total cost of items in stock: %s\n", NumberFormat.getCurrencyInstance().format(itemCost()));
return sb.toString();
}
}
public static void displayNext() {
if (presentItem == produceItem.length - 1) {
displayFirst();
}
else {
presentItem++;
}
}
public static void displayFirst() {
presentItem = 0;
}
public static void displayFinal() {
presentItem = produceItem.length - 1;
}
public static String[] getStringArray() {
String[] presentStringArray = new String[5];
presentStringArray[0] = produceItem[presentItem].getItem();
presentStringArray[1] = produceItem[presentItem].getLocalMarket();
presentStringArray[2] = Integer.toString(produceItem[presentItem].getSku());
presentStringArray[3] = Integer.toString(produceItem[presentItem].getNumCases());
presentStringArray[4] = Double.toString(produceItem[presentItem].getCasePrice());
return presentStringArray;
}
public static int getNextProduceItem() {
int newSku = 0;
for (int y = 0; y < produceItem.length; y++){
if (produceItem[y].getSku() > newSku) {
newSku = produceItem[y].getSku();
}
}
return newSku +1;
}
public static void addProduceItem(String localMarket, String item,
int sku, int numCases, double casePrice) {
String[] newFarmersMarket = new String[5];
newFarmersMarket[0] = item;
newFarmersMarket[1] = localMarket;
newFarmersMarket[2] = Integer.toString(sku);
newFarmersMarket[3] = Integer.toString(numCases);
newFarmersMarket[4] = Double.toString(casePrice);
addFarmersMarket(newFarmersMarket);
}
public static void addFarmersMarket(String[] info) {
ProduceInfo pInfo = new ProduceInfo(getNextProduceItem(), info[0],info[1],
Integer.valueOf(info[2]), Integer.valueOf(info[3]),Double.valueOf(info[4]));
Class elementType = produceItem.getClass().getComponentType();
ProduceInfo[] newArray = (ProduceInfo[])
java.lang.reflect.Array.newInstance(elementType, produceItem.length +1);
System.arraycopy(produceItem, 0 , newArray, 0 , produceItem.length);
newArray [newArray.length - 1] = pInfo;
produceItem = newArray;
displayFinal();
displayFirst();
}
}
package farmersmarket3;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* @author Lynn
*/
class ProduceGUI implements ActionListener {
static JPanel jplAdvanced;
static JPanel jplNavigation;
static JButton jbnNext;
static JLabel jlbLabel;
static JFrame jfrMain;
static JTextArea jtxtArea;
public ProduceGUI() {
jplAdvanced = new JPanel();
jplNavigation = new JPanel();
jlbLabel = new JLabel();
jlbLabel.setText("Farmers Market Program");
jfrMain = new JFrame("Market Inventory");
jfrMain.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
jtxtArea = new JTextArea();
jtxtArea.append(FarmersMarket3.getPresentTotalString());
jfrMain.getContentPane().add(jtxtArea);
jbnNext = new JButton("Next");
jbnNext.addActionListener(this);
jbnNext.setActionCommand("next");
jplAdvanced.add(jbnNext);
jplNavigation.add(jlbLabel);
jfrMain.pack();
jfrMain.setVisible(true);
jfrMain.getContentPane().add(jplNavigation, BorderLayout.PAGE_START);
jfrMain.getContentPane().add(jtxtArea, BorderLayout.WEST);
jfrMain.getContentPane().add(jplAdvanced, BorderLayout.PAGE_END);
}
private static void displayPresentTotal() {
jtxtArea.setText(FarmersMarket3.getPresentTotal());
}
public static void enableButtons (boolean enable) {
jbnNext.setEnabled(enable);
}
public void actionPerformed (ActionEvent e) {
if ("next".equalsIgnoreCase(e.getActionCommand())) {
FarmersMarket3.displayNext();
displayPresentTotal();
}
}
}
The error in the code above is where it says displayPresentTotal. Thank you all once again.