Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 2 Weeks Ago   #1 (permalink)
4.0 GHz
 
mojoopo's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Canada
Posts: 1,168

Rep: 28 mojoopo is acknowledged by some
Unique Rep: 25
FAQs Submitted: 1
Hardware Reviews: 1
Trader Rating: 1
Default Help with Java Pizza

Ok so i am working on an assignment and iv been trying to figure out the error i am getting when compling heres a screen shot of the error and below is the code:

Code:
public class DemoSwitch
{

    public static void main(String args[])
    {
        char num = 's';
        String checksize;

        switch(num)
        {
            case 's' :   checksize = "Small";
                       break;
            case 'm' :   checksize = "Medium";
                       break;
            case 'l' :   checksize = "Large";

            
        }

        if ((checksize == "Small")||(checksize == "Medium")||(checksize == "Large"))
        {
            System.out.println("Your Size is: " + checksize);
        }
            

        else
        {
            System.out.println("Invalid");
        }
            
    }

    
}
Attached Thumbnails
Help with Java Pizza-error1.jpg  
__________________
3


System: The Build
CPU
Intel Core I7 920 D0 @ 4.2GHz
Motherboard
Asus P6T Deluxe V2
Memory
Mushkin HP3 1600Mh 6Gb
Graphics Card
2X GTX275 896MB
Hard Drive
WD Black 500GB
Sound Card
Onboard 7.1
Power Supply
750w Coarsair TX750
Case
Thermaltake Armour Jr.
CPU cooling
Scythe Mugen 2
GPU cooling
AC Xtreme 280
OS
Windowsw 7 Ultimate 64Bit
Monitor
Dynex 32Inch TV
mojoopo is offline   Reply With Quote
Old 2 Weeks Ago   #2 (permalink)
Programmer
 
intel nvidia

Join Date: Oct 2006
Posts: 327

Rep: 36 danewfie is acknowledged by some
Unique Rep: 33
Trader Rating: 0
Default

String checksize = null;

You never set checksize to anything.

So checksize would need a value of some sort in order for it to check against another variable
__________________
-Every Rose has its thorn
My Blog

System: My System
CPU
Q6600
Motherboard
EVGA 680i SLI A1
Memory
4gig Balistix 8500 DDR2
Graphics Card
EVGA 8800GT 512mb
Hard Drive
4x 500gig WD
Sound Card
X-FI Platinum
Power Supply
Antec Trio 650W
Case
Antec P182
OS
XP Pro
Monitor
Westinghouse 37''
danewfie is offline   Reply With Quote
Old 2 Weeks Ago   #3 (permalink)
4.0 GHz
 
mojoopo's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Canada
Posts: 1,168

Rep: 28 mojoopo is acknowledged by some
Unique Rep: 25
FAQs Submitted: 1
Hardware Reviews: 1
Trader Rating: 1
Default

ah yes right before u posted i figured it ou what i did was this.. thanks but maybe u could help me out i will make a seperate post below this of whta my real problem is now with my three classes...

Code:
public class DemoSwitch
{

    public static void main(String args[])
    {
        char num = 'x';
        String checksize;

        switch(num)
        {
            case 's' :   checksize = "Small";
                       break;
            case 'm' :   checksize = "Medium";
                       break;
            case 'l' :   checksize = "Large";
                       break;
            default  :     checksize = "Invalid";
            
        }

        if ((checksize == "Small")||(checksize == "Medium")||(checksize == "Large"))
        {
            System.out.println("Your Size is: " + checksize);
        }
            

        else
        {
            System.out.println("Invalid Size");
        }
            
    }

    
}
__________________
3


System: The Build
CPU
Intel Core I7 920 D0 @ 4.2GHz
Motherboard
Asus P6T Deluxe V2
Memory
Mushkin HP3 1600Mh 6Gb
Graphics Card
2X GTX275 896MB
Hard Drive
WD Black 500GB
Sound Card
Onboard 7.1
Power Supply
750w Coarsair TX750
Case
Thermaltake Armour Jr.
CPU cooling
Scythe Mugen 2
GPU cooling
AC Xtreme 280
OS
Windowsw 7 Ultimate 64Bit
Monitor
Dynex 32Inch TV
mojoopo is offline   Reply With Quote
Old 2 Weeks Ago   #4 (permalink)
4.0 GHz
 
mojoopo's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Canada
Posts: 1,168

Rep: 28 mojoopo is acknowledged by some
Unique Rep: 25
FAQs Submitted: 1
Hardware Reviews: 1
Trader Rating: 1
Default

so here is the big problem... the point of this assignment was to make a program that accepts 2 arguments of which only the first letter of each is read so i understand i would have to use the .charAt method to read Them

after it reads the strings and accepts the char values it is supposed to switch them out for strings after it has done that it must check the validity of the switch and output a message saying either ("your size is: +checksize") or ("invalid size") i understand that part

so here is the point of my problem i dont know how to get my argument that i inputed into my checkorder class from my orderform class? both the orderform and the check order use my pizza class.

here are my three classes so far...

Code:
/**
 * Write a description of class Pizza here.
 * 
 * @author Michael Wojtysiak 
  * @version 1.1
 */
public class Pizza
{
   private String size;
   private String toppings;
   private static int PizzasSold;
 
   
   public  Pizza()
   {
       System.out.println("Pizza One - Default Constructor");
       setSize("Small");
       setToppings("Regular");
       System.out.println("Size: " + size);
       System.out.println("Toppings: " + toppings);
       System.out.println("");
    }
    
    public Pizza(String setSize, String setToppings)
    {
        this.size = setSize;
        this.toppings = setToppings;
        System.out.println("Pizza Three - Two Parameter Constructor");
        System.out.println("Size: " + size);
       System.out.println("Toppings: " + toppings);
       System.out.println("");
    }
    
    public Pizza(String setSize)
    {
        setSize("Medium");
        setToppings("Regular");
        System.out.println("Pizza Two - One Parameter Constructor");
        System.out.println("Size: " + size);
        System.out.println("Toppings: " + toppings);
        System.out.println("");
    }
    
    public void setSize(String size)
    {
        this.size = size;
    }
    
    public void setToppings(String toppings)
    {
        this.toppings = toppings;
    }
    
    public String getSize()
    {
        return this.size;
    }
    
    public String getToppings()
    {
        return this.toppings;
    }
    
    public static int getPizzasSold()
    {
        return PizzasSold;
    }
    
   // public boolean equal(Pizza CompPizza)
   // {
      //  if(this.getSize()==(CompPizza.getSize()))
       // {
         //   if(this.getToppings()==(CompPizza.getToppings()))
         //   {
          //      return true;
            //}
          //  else
           // {
           //     return false;
          //  }
       // }
      //  return false;
   // }
    
          public boolean equal(Pizza CompPizza)
    {
        if(this.getSize()==(CompPizza.getSize()))
        {
            if(this.getToppings()==(CompPizza.getToppings()))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        return false;
    }
        private void calculatePrice()
    {

    }
    
    
    public void display(String size, String toppings, double price)
    {
        System.out.println("Size: " + size);
        System.out.println("Toppings: " + toppings);
        System.out.println("Price: " + price);
        
    }
    

    

}
Code:
import java.util.Scanner;

/**
 *Has Pizzas
 * 
 * @author Michael Wojtysiak
  * @version 1.1
 */
public class OrderForm
{
public static void main(String args[])
    {

        
            String mySize = args[0];
            String myToppings = args[1];
           


            CheckOrder.checkSize(args[0]);
           // CheckOrder.checkTopping(args[1]);
           
           Pizza One = new Pizza();
           Pizza Two = new Pizza(mySize);
           Pizza Three = new Pizza(mySize,myToppings);
           

            
            
           boolean Res = Three .equal(One);
           if(Res == true)
           {
               System.out.println("They are the same!");
            }
            else
            {
                System.out.println("They are different!");
            }
            
        


 
    } 
}
Code:
/**
 * Write a description of class CheckOrder here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class CheckOrder
{
   public static boolean checkSize(String size)
   {
           char num = size;
        String checksize;

        switch(num)
        {
            case 's' :   checksize = "Small";
                       break;
            case 'm' :   checksize = "Medium";
                       break;
            case 'l' :   checksize = "Large";
                       break;
            default  :     checksize = "Invalid";
            
        }

        if ((checksize == "Small")||(checksize == "Medium")||(checksize == "Large"))
        {
            System.out.println("Your Size is: " + checksize);
        }
            

        else
        {
            System.out.println("Invalid Size");
        }
      
       

       

    }

           //if(boolean checkSize = true)
           //{
             //  size = "Small";
           // }
            //else
            //{
            //    System.out.println("Invalid");
           // }
        
    

   
}
__________________
3


System: The Build
CPU
Intel Core I7 920 D0 @ 4.2GHz
Motherboard
Asus P6T Deluxe V2
Memory
Mushkin HP3 1600Mh 6Gb
Graphics Card
2X GTX275 896MB
Hard Drive
WD Black 500GB
Sound Card
Onboard 7.1
Power Supply
750w Coarsair TX750
Case
Thermaltake Armour Jr.
CPU cooling
Scythe Mugen 2
GPU cooling
AC Xtreme 280
OS
Windowsw 7 Ultimate 64Bit
Monitor
Dynex 32Inch TV
mojoopo is offline   Reply With Quote
Old 2 Weeks Ago   #5 (permalink)
4.0 GHz
 
mojoopo's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Canada
Posts: 1,168

Rep: 28 mojoopo is acknowledged by some
Unique Rep: 25
FAQs Submitted: 1
Hardware Reviews: 1
Trader Rating: 1
Default

also heres the instructions on the powerpoint that i was givin maybe they can explain my point better then i can
Attached Files
File Type: pdf assignment5.pdf (77.9 KB, 5 views)
__________________
3


System: The Build
CPU
Intel Core I7 920 D0 @ 4.2GHz
Motherboard
Asus P6T Deluxe V2
Memory
Mushkin HP3 1600Mh 6Gb
Graphics Card
2X GTX275 896MB
Hard Drive
WD Black 500GB
Sound Card
Onboard 7.1
Power Supply
750w Coarsair TX750
Case
Thermaltake Armour Jr.
CPU cooling
Scythe Mugen 2
GPU cooling
AC Xtreme 280
OS
Windowsw 7 Ultimate 64Bit
Monitor
Dynex 32Inch TV
mojoopo is offline   Reply With Quote
Old 2 Weeks Ago   #6 (permalink)
4.0 GHz
 
mojoopo's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Canada
Posts: 1,168

Rep: 28 mojoopo is acknowledged by some
Unique Rep: 25
FAQs Submitted: 1
Hardware Reviews: 1
Trader Rating: 1
Default

sorry bout the bump but i really really need help with this it is due at 12 am est
__________________
3


System: The Build
CPU
Intel Core I7 920 D0 @ 4.2GHz
Motherboard
Asus P6T Deluxe V2
Memory
Mushkin HP3 1600Mh 6Gb
Graphics Card
2X GTX275 896MB
Hard Drive
WD Black 500GB
Sound Card
Onboard 7.1
Power Supply
750w Coarsair TX750
Case
Thermaltake Armour Jr.
CPU cooling
Scythe Mugen 2
GPU cooling
AC Xtreme 280
OS
Windowsw 7 Ultimate 64Bit
Monitor
Dynex 32Inch TV
mojoopo is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 11:59 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.12337 seconds with 9 queries