Register for your free account! | Forgot your password?

Go Back   elitepvpers > Off-Topics > Off Topic
You last visited: Today at 15:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



real off topic but please help

Discussion on real off topic but please help within the Off Topic forum part of the Off-Topics category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2006
Posts: 45
Received Thanks: 3
real off topic but please help

I am currently in school for programming. I need to write some code that contains; a constructor, an override and an overload. I think i have the constructor and overload, however i can not seem to get the override to work. Any help is greatly appreciated. My tutor called off, and im stuck so i turn to the masters please help me fix this

class Pizza { // declare pizza class
int size; //declare variable for pizza size

Pizza() {
System.out.println("Order a Pizza"); // declare pizza
size = 0;
}

Pizza(int i) {
System.out.println("Ordering a " + i + " inch pizza"); //declare pizza count
size = i;
}

void info() {
System.out.println("Pizza size is " + size + " inches"); // print pizza and size
}

void info(String s) {
System.out.println(s + ": Pizza size is " + size + " inches"); // print pizza, size and string
}
} // end pizza class

class PizzaShop extends Pizza { // declare pizza subclass
int size; //declare variable for pizza size

PizzaShop() {
System.out.println("Customer Ordered a Pizza"); // declare pizza
size = 0;
}

PizzaShop(int i) {
System.out.println("Customer Ordered a " + i + " inch pizza"); //declare pizza count
size = i;
}

void info() {
System.out.println("Customer's Pizza size is " + size + " inches"); // print pizza and size
}

void info(String s) {
System.out.println(s + ":Customer's Pizza size is " + size + " inches"); // print pizza, size and string
}

public void main(String[] args) { // declare main
for (int i = 5; i < 27; i += 4) { // set i to 10increment by 4 up to and inlcude 26
PizzaShop p = new PizzaShop(i); // set pizza constructor
p.info(); // 1 pizza declare
p.info("overloaded method"); //2 pizza declare
//PizzaShop myPizzaShop = new PizzaShop();
// Pizza myPizza = myPizzaShop;


}

// Overloaded constructor:
new PizzaShop(); // return pizza
}
}// end pizzashop subclass
public class JavaOverloading { //declare javaoverload class

public static void main(String[] args) { // declare main
for (int i = 10; i < 27; i += 4) { // set i to 10increment by 4 up to and inlcude 26
Pizza p = new Pizza(i); // set pizza constructor
p.info(); // 1 pizza declare
p.info("overloaded method"); //2 pizza declare
}
// Overloaded constructor:
new Pizza(); // return pizza
PizzaShop obj = new PizzaShop();
obj.info();

}

}

// end javaoverload class
mrsnuffy is offline  
Old 10/14/2008, 00:02   #2
 
Kuh's Avatar
 
elite*gold: 343
Join Date: Nov 2006
Posts: 7,088
Received Thanks: 1,775
I'm sorry but we cant really help you here, we are just a bunch of random spamming nups i suggest you try or even

I'm sure you will get a better answer there, i could help you with visual basic xD i learned that a few years ago but was to lazy to carry on my interest in other languages (btw think i had to do even the same "pizza order" task back then xD)
Kuh is offline  
Thanks
1 User
Old 10/14/2008, 07:34   #3
 
elite*gold: 0
Join Date: Feb 2006
Posts: 45
Received Thanks: 3
i got it thanks

I finally figured it out thanks, the code is made up, only assingment was to use constructor, override and overload, just so happend to use pizza cause i had it for dinner lol
mrsnuffy is offline  
Old 10/14/2008, 14:01   #4
 
elite*gold: 0
Join Date: Aug 2007
Posts: 6,009
Received Thanks: 610
Post the right code please.
DarkCronicLe is offline  
Old 10/15/2008, 02:08   #5


 
elite*gold: 0
Join Date: Apr 2008
Posts: 8,636
Received Thanks: 1,581
pizza shop?
Rawsteeey is offline  
Old 10/16/2008, 17:33   #6
 
BlackFog's Avatar
 
elite*gold: 105
Join Date: Mar 2007
Posts: 5,073
Received Thanks: 558
Pizza is good !!
BlackFog is offline  
Reply




All times are GMT +2. The time now is 15:23.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.