pb:
I'm still having error codes with that, even after taking the methods out of the main.
Errors:
CoffeeDriver.java:37: missing method body, or declare abstract
private static void sortPrice(Item array[]);
^
CoffeeDriver.java:41: cannot find symbol
symbol : variable array
location: class CoffeeDriver
for (x = 0; x < array.length; x++)
^
CoffeeDriver.java:43: cannot find symbol
symbol : variable array
location: class CoffeeDriver
if(array[x].getPrice() > array[x+1].getPrice())
^
CoffeeDriver.java:43: cannot find symbol
symbol : variable array
location: class CoffeeDriver
if(array[x].getPrice() > array[x+1].getPrice())
^
CoffeeDriver.java:45: cannot find symbol
symbol : variable array
location: class CoffeeDriver
temp = array[x];
^
CoffeeDriver.java:46: cannot find symbol
symbol : variable array
location: class CoffeeDriver
array[x] = array[x+1];
^
CoffeeDriver.java:46: cannot find symbol
symbol : variable array
location: class CoffeeDriver
array[x] = array[x+1];
^
CoffeeDriver.java:47: cannot find symbol
symbol : variable array
location: class CoffeeDriver
array[x+1] = temp;
^
CoffeeDriver.java:50: cannot find symbol
symbol : variable array
location: class CoffeeDriver
System.out.println(array[x]);
^
CoffeeDriver.java:52: missing method body, or declare abstract
private static void sortName(Item arr[]);
^
CoffeeDriver.java:56: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
for (x = 0; x < arr.length; x ++)
^
CoffeeDriver.java:58: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
if(arr[x].getName().compareTo(arr[x+1].getName) > 0)
^
CoffeeDriver.java:58: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
if(arr[x].getName().compareTo(arr[x+1].getName) > 0)
^
CoffeeDriver.java:60: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
temp = arr[x];
^
CoffeeDriver.java:61: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
arr[x] = arr[x+1];
^
CoffeeDriver.java:61: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
arr[x] = arr[x+1];
^
CoffeeDriver.java:62: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
arr[x+1] = temp;
^
CoffeeDriver.java:64: cannot find symbol
symbol : variable arr
location: class CoffeeDriver
System.out.println(arr[x]);
^
Item.java:9: missing method body, or declare abstract
public String getName();
^
Item.java:11: return outside method
return itemName;
^
Item.java:15: return outside method
return itemPrice;
^
- import java.util.Arrays;
-
import javax.swing.JOptionPane;
-
public class CoffeeDriver
-
{
-
public static void main (String[] args)
-
{
-
String userInput;
-
int x;
-
int selectSort;
-
Item arr[] = new Item[5];
-
arr[0] = new Item("Coffee", 1.00);
-
//....etc
-
}
-
-
private static void sortPrice(Item array[]);
-
{
-
int x;
-
Item temp;
-
for (x = 0; x < array.length; x++)
-
{
-
if(array[x].getPrice() > array[x+1].getPrice())
-
{
-
temp = array[x];
-
array[x] = array[x+1];
-
array[x+1] = temp;
-
}
-
}
-
System.out.println(array[x]);
-
}
-
private static void sortName(Item arr[]);
-
{
-
int x;
-
Item temp;
-
for (x = 0; x < arr.length; x ++)
-
{
-
if(arr[x].getName().compareTo(arr[x+1].getName) > 0)
-
{
-
temp = arr[x];
-
arr[x] = arr[x+1];
-
arr[x+1] = temp;
-
}
-
System.out.println(arr[x]);
-
}
-
}
-
}
-
- public class Item
-
{
-
private String itemName;
-
private double itemPrice;
-
public String getName();
-
{
-
return itemName;
-
}
-
public double getPrice;
-
{
-
return itemPrice;
-
}
-
public Item ()
-
{
-
//use this for my temp sorting!
-
}
-
public Item (String itemName, double itemPrice)
-
{
-
this.itemPrice = itemPrice;
-
this.itemName = itemName;
-
}
-
public void setItemName(String someItem)
-
{
-
itemName = someItem;
-
}
-
public void setItemPrice(double somePrice)
-
{
-
itemPrice = somePrice;
-
}
-
}