User Profile

Collapse

Profile Sidebar

Collapse
Misaio
Misaio
Last Activity: Mar 8 '10, 02:46 AM
Joined: Mar 5 '10
Location: Maine
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Alright, so I'm just working on the price method right now. It seems to go rather well until I get to the output. I get this bizarre thing that I'm sure many of you have seen before.

    [Item@fabe9, Item@df6ccd, Item@601bb1, Item@1ba34f2, Item@1ea2dfe]

    I looked up the odd outputs and was told that Arrays.deepToSt ring(arrays)); would help. Here is the method I'm working with. But as I print it out again...I still get...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    I'm still trying to figure out just what I'm trying to do with this. This is what I started with:
    Code:
    	public static void sortPrice(Item array[])
    	{
    		int x;
    		int j =0;
    		Item temp;
    			while (j < 5)
    			{
    				j++;
    				for (x = 0; x < array.length; x++)
    				{	
    					if(array[x].getPrice() > array[x+1].getPrice())
    					{
    						temp = array[x];
    ...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Yeah, I was having problems with my output and looking into ways of sorting it. I was hoping I wouldn't need a nested loop, but...I have to go with what works, right? I'll check Wiki.
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Is there anyway someone can take that last post out? The errors were completely my oversight. I put a lot of extra ;'s in there, but a nap and some coffee allowed me to wake up and see it.
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    pb:

    I'm still having error codes with that, even after taking the methods out of the main.

    Errors:
    CoffeeDriver.ja va:37: missing method body, or declare abstract
    private static void sortPrice(Item array[]);
    ^
    CoffeeDriver.ja va:41: cannot find symbol
    symbol : variable array
    location: class CoffeeDriver
    for (x = 0; x < array.length; x++)
    ...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Alright, so now I have what I believe is a nice way to hold both pieces of the corresponding data under one [x].

    Code:
    		Item arr[] = new Item[5];
    		arr[0] = new Item("Coffee", 1.00);
    		arr[1] = new Item("Water", 2.00);
    		arr[2] = new Item("Milk", 1.50);
    		arr[3] = new Item("Bagel", 1.25);
    		arr[4] = new Item("Donut", 0.75);
    Now my...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Thanks mate! This should keep me busy for the remainder of the night. It's nice to see some experts around here that are so willing to help. I'll keep you posted with the results!
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Oh! Another question...you mentioned that:
    Code:
    9.	        // B
    10.	    int selectSort;
    11.	    // TODO: Use a JOptionPane to give selectSort the appropriate value
    But I was under the impression that since I was getting it as user input that it was a String by default and that I should parse it to an int. That's why userInput and selectSort were so different.

    Code:
    	userInput = JOptionPane.showInputDialog(null,
    ...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    pb:

    Thank you, thank you, thank you! I think I see just what you're talking about now. And thank you for just explaining what I'm missing rather than showing me code. I don't want to get in trouble for that. I really want to write the code myself, not copy and paste. Let me try to revamp my code and I'll keep you updated. Hopefully, I'll be able to finish this quickly! So don't go far. Heh.

    ~Missy

    PS:...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Now I'm a little less confused on what I need. Thank you! Now...how do I go about putting the item with the price in one array? And was I right to attempt to define the item objects in the constructor? I know, I sound like a really dim girl, but I'm doing my best to fully grasp the terms and how these concepts are applied, I promise. I really want to learn the basics of programming so I can move on to better things.
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    Alright, I was actually giving this a shot to see what I could put together. I know, I'm missing a lot of the key elements, but so far, how does it look?

    Code:
    import java.util.Arrays
    import javax.swing.JOptionPane;
    public class CoffeeDriver
    {
    	public static void main (String[] args)
    	{
    		String userInput;
    		int x;
    		int selectSort;
    		String[] someItem = new String[5];
    ...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to Beginner to Java: Constructors and Sorts
    in Java
    I think I'm supposed to use two arrays for the project. Let me grab some of the criteria for you. I have started to put some of the code together, but I'm confused as to where I declare the array objects. Also, I was told that bubble sorting would be a good way to try this, but I've never used it. Can anyone give me information on that?

    This project will require 2 classes. The first will be the data definition class and the second...
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to How do I create an array using user input?
    in Java
    Thanks so much, Anurag! This really helped me out. And it's something I hadn't read in my Java books yet.
    See more | Go to post

    Leave a comment:


  • Misaio
    replied to How do I create an array using user input?
    in Java
    Actually, I don't think I'm that far in my Java yet. But what I did find was that I could loop the input and just parse it into a secondary array like this:

    Code:
    	for (x = 0; x < PLACE_HOLDER; ++x)
    		{
    			stringArray[x] = JOptionPane.showInputDialog(null, "Please input the price of the item you ordered.");
    			doubleArray[x] = Double.parseDouble(stringArray[x]);
    		}
    This way, I could...
    See more | Go to post

    Leave a comment:


  • Misaio
    started a topic Beginner to Java: Constructors and Sorts
    in Java

    Beginner to Java: Constructors and Sorts

    I am a beginner programmer and am having trouble with constructors and sorts. What's worse is that I am not used to programming in two different classes. It's making my head spin looking back and forth trying to trace the different names.

    The idea behind the project is that I'm going to have two sets of arrays. One with item names and the other with the corresponding prices of said items. The user will be asked how they wish to...
    See more | Go to post

  • Misaio
    started a topic How do I create an array using user input?
    in Java

    How do I create an array using user input?

    I'm trying to create a program that prompts the user to put in several different numbers. I'd like to put those numbers into an array for easy use. To save me time on coding, I want to loop the request for user input. Would I use a for loop and use the subscript in the array to make changes as needed? Please help.
    See more | Go to post
No activity results to display
Show More
Working...