• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

missing return statement

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!

I am currently trying to complete this https://www.dropbox.com/s/vfaz5jhjmbm2p2v/BlueJHelpMe.doc?dl=0tassignment[/url] (It's overdue because I have been stuck on what to do for the last day)

I have completed the Product class, and I am currently completing the Store class.




So as you can see I've mostly completed Product. First of all, if someone would be so kind to check this over and point out anything I did wrong, i'd appreciate it. I am having trouble with the



BlueJ is saying "missing return statement" and I have no idea how to fix it. If anyone could point me in the right direction I'd appreciate it. Also, I'll post my store class in the comments and i have an error there too...
 
callam falconer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



(NOTE: In my class at this current point in time we were not allowed to add Arrays so please forgive me for the unneccesary amount of if statements!)

When ever I compile this, the bottom bit (getOrder) will never find the getOrder in Product class. I can't wrap my head around this as I thought I was declaring the method well in the Product class.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

callam falconer wrote:I am having trouble with the



BlueJ is saying "missing return statement" and I have no idea how to fix it. If anyone could point me in the right direction I'd appreciate it. Also, I'll post my store class in the comments and i have an error there too...



If the "if" condition block executes (meaning else doesn't execute), then what should the method return?

Henry
 
callam falconer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

callam falconer wrote:I am having trouble with the



BlueJ is saying "missing return statement" and I have no idea how to fix it. If anyone could point me in the right direction I'd appreciate it. Also, I'll post my store class in the comments and i have an error there too...



If the "if" condition block executes (meaning else doesn't execute), then what should the method return?

Henry



hi Henry

I'm not sure what you mean (very new!) I'm trying to return 0 as the assignment tells me. Can you explain in further detail?

Thanks!
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right. The assignment says "If (such and such) is true then return zero". And yes, you did that. But what if (such and such) isn't true? You have to return something, that's a rule of Java. (Hence the compiler error message.) So, what should you return? The assignment doesn't explicitly say what you should return so it's up to you to read between the lines in the assignment.

(By the way it's normal for programmers to work from specs which aren't quite perfect. That's what you have to do here.)

EDIT: Actually now that I reread the specs, they do explicitly say what you should return. Read them again.
 
callam falconer
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Right. The assignment says "If (such and such) is true then return zero". And yes, you did that. But what if (such and such) isn't true? You have to return something, that's a rule of Java. (Hence the compiler error message.) So, what should you return? The assignment doesn't explicitly say what you should return so it's up to you to read between the lines in the assignment.

(By the way it's normal for programmers to work from specs which aren't quite perfect. That's what you have to do here.)

EDIT: Actually now that I reread the specs, they do explicitly say what you should return. Read them again.



Thanks so much, it took me a bit to understand but I eventually got it and wooo no Syntax errors!

I posted the exact same thing on Reddit and Stackoverflow and received some shade from more experienced programmers, I'm glad I joined a community that is friendly towards noobs.

Again, thanks a lot!
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, StackOverflow does have that reputation. Anyway, glad you're back on track.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic