• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Date details method is not showing up into the terminal  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, does anyone know why my date details method is not showing up into the terminal?   I have declared the parameter and called the argument in main. I am wondering if it has something to do with the lessonsList method code above. I am not too sure as I am not receiving any errors in net beans


 
Master Rancher
Posts: 920
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the code shown it seems your main is in the BookingController?
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about because I made the object instance of the booking controller called details on this line to call the methods?    The code works fine but my output only shows up like  below  and does not show the DateDetails method despite the fact that I thought I declared the method call properly   such as the param

and the argument call in the main



I have not received any errors the method just not showing up in the terminal and not to sure why


The output just displays as below


 
Daniel Demesmaecker
Master Rancher
Posts: 920
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This might be your problem, the scanner is waiting for input from the user...
So remove the sc.nextInt();
There's also something wrong with your dateformat, when I run your code the current date is 10/41/2019
This:
will also give a prob, put   y = sc.nextInt(); in your if statement
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wonderful that works, but I notice sometimes it works but sometimes it does work is there any way I can make it work all the time
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sometimes it work and sometime it does not work *
 
Daniel Demesmaecker
Master Rancher
Posts: 920
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When is'nt it working? What is your output?
 
Marshal
Posts: 62231
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zara bailey wrote:. . . I have declared the parameter and called the argument in main. . . . .

You mean you declared a parameter in dateDetails() and declared a Date variable, which you passed to that method and you aren't doing anything with there. Please confirm you are posting the real code you are using rather than writing it anew. In which case, print out that date and work out why it reads 1st January 1970.
Maybe you are getting your execution blocked by the nextInt() call, but the whole of that block looks confused. What does y mean? What happens if you enter 1 for one lesson and you get to the if? Then you are asking for another y in line 55, but not telling the user what to do. As DD says, each of those nextInt() calls will block if given no input. And you appear to be confused about how many lessons you can have: up to 3? In which case why is lESSON_COUNT (sic.) set to 4?
Sorry about this, but I think your code needs a lot of changes, and it might be easier to delete the lot Sorry, but it has got a lot wrong with it.
Something like dateDetails() is a bad name for a method because it doesn't make it obvious what the method does. I would think it means it gives the details of the date. A name like setDate() would be better. And details is a bad name for a controller.
Stop using the Date class. Horrible thing to use. Use the Java8+ date classes instead.
Your methods are all too long, which suggests they are trying to do several things. That isn't good; a method should do one thing only, Either set the date from information passed as an argument, or create a date from details from the keyboard. Don&apo;t try both in the same method. And don't have the side‑effect of reassigning s, whose meaning you might have remembered if it had a better name. By the way: I think your date format String is incorrect; check the meanings of the letters particularly m here.
A name even worse is customerName. It might be obvious what it is supposed to mean, but it also makes me suspect it is in the wrong place. I think it should be in the Customer class. In which case, have you got a Customer class?And have you got a Lesson class?
How much thought and design did you give this code before you wrote it? It reads like code where somebody is simply throwing bits together and hoping for the best. Unfortunately that is a reasonably reliable way to get the worst. Sorry to appear so negative about your work.
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after the changes.

the output is still below



when I take out this code completely at the end of the lessons array




I get this output. so I am wondering to cut the lesson array short to exclude those parts of code above so that the next element would show

here is the output when I exclude those parts

run:
###############################################
Welcome to the Weekend Fitness Gym
###############################################
Please enter your name(Last, First)
Bill
Plase enter age
22
###############################################
PLEASE SELECT LESSON
###############################################
1. Zumba
2. Spin
3. Yoga
4. BodyScuplt
Please select the values between 1-3 to book lessons
1
You have selected lesson Zumba
Can you please re-enter selection.
###############################################
PLEASE SELECT BOOKING DATE
###############################################
Current Date Is 06/10/2019 12:10:47
Please select Date
You have booked lesson for the
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell Ritchie,

Yes I know the code is not perfect and I am trying, unfortunately, I am running out of time and I am trying to do what I can do. I am not looking for a perfect code at the moment just something that meets all the requirements. If you run the code the code listing actually works and the functionality does what is supposed to do. I was told to do "x" and "y" variables in decision statements like that instead of long words
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this is the current code I am working on now since other changes in other posts I have made changes . and what I have posted is current code
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have attached an image of my code and yes I have lesson class and customer class and in those classes, I have set getters and setters and constructors. The booking class is where I am hard coding everything. I have thought this through i just need some sense of direction that is all
classes.JPG
[Thumbnail for classes.JPG]
 
Daniel Demesmaecker
Master Rancher
Posts: 920
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is based on your code that I copied and pasted in my ide:

but I would take C.R's advice to heart
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Thanks
 
Daniel Demesmaecker
Master Rancher
Posts: 920
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind that I removed your customerDetails
 
Zara bailey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You very much and the advise has been very helpful once again
 
Seriously? That's what you're going with? I prefer this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!