• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java code help  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some help adding code to the makeAppointment method of this code to do the following:

The code that needs added should be able to:

1.Make a 1 hour appointment at 9AM (should succeed)

2.Make a 1 hour appointment at 5 PM (should succeed)

3.Make a 2 hour appointment at 9 AM (should succeed)

4.Make a 2 hour appointment at 4 PM (should succeed)

5.Make a 2 hour appointment at 5 PM (should fail and 5PM slot should NOT be filled)*

6.Make a 3 hour appointment at 9 AM (should succeed)

7.Make a 3 hour appointment at 4 PM (should fail and 4 PM and 5 PM slots should NOT be filled)*




Will the boolean method of (add) work for solving or adding the particular code?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, and welcome to the Ranch!

What particular problem are you having? You need to ShowSomeEffort(⇐click) adn TellTheDetails(⇐click) about what specifically you're having trouble with.

Also, when posting code, please UseCodeTags(⇐click) so it will be readable.
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the method starts filling the time slots for the appointment, does it know whether they are actually available?
 
Ronald Mukkia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I originally added all the code for the issue at hand, but edited it out. I'm very...very new to this, so I'm learning as I go. I appreciate all and anyones help!
I will repost with all the code.


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still need to ask an actual question.
 
Ronald Mukkia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you input the parameters when using "makeAppointment" from an instance of the day class?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R Mu wrote:how do you input the parameters when using "makeAppointment" from an instance of the day class?


So, you're asking how to take input from the user?

Or you're asking how to pass parameters to a method?

Or something else?
 
Ronald Mukkia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to pass parameters to a method?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ronald Mukkia wrote:how to pass parameters to a method?


I think it may be a good idea to step back a bit.... and try out the Oracle Java tutorial.

http://docs.oracle.com/javase/tutorial/java/TOC.html




Or if you like, just look at how to create methods...

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

And how to pass parameters to it.

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

Henry
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you "add the code for the issue at hand", if you don't understand what you are doing?

Writing code isn't easy. You can't just throw stuff together and hope it works, and if not keep throwing more stuff at it. You need to stop, think through every aspect of what you want to do, then write code in EXTREMELY small chunks. I never never never write more that 3 new lines before I re-compile, test, and debug what I've written.

Yes, this requires me to write a ton of code that I later throw away - lots of 'helper' methods, lots (and i mean LOTS) of System.out.println() statements, lots of methods that don't really DO anything but return a dummy value.

There has to be more to your specs that what you list. If those 7 things were all that were required, you could do it with a few simple "if" statements:


I'm pretty sure that is NOT what you want.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!