• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Validation Problem

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I need help on how to approach the solution to the problem, rather than actual code.

In my assignment I have a class called VehicleRecord which has two fields: String registrationDate and String expiryDate.

This class must include validation methods (for validating the data supplied by the user for the fields) and I have to use the following method signature; .

The above validation method has to be used for validating two different dates, registrationDate and expiryDate (both with the same validation parameters : 4 digits (MMDD) date range = 0181 -> 1220) after the user has supplied them but [ITALIC]before[/ITALIC] the supplied data is passed to the respective field.

I have coded the actual validation and it works fine.

The problem I have is that the method signature does not allow for any returned value. Due to this, I do not see a way that the validation method can tell which date it is validating, so the following cannot happen...

... because which fields date is the method validating.

I am restricted by the terms of the assignment but if I were not, I would go about it as follows (in fact I have and this approach works fine).

... but I cant use the above approach.

Can anyone suggest a way to approach this problem?

Thank you
[ July 22, 2004: Message edited by: Darren Wilkinson ]
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why dont you use

and then change it in your validation method according to wheter valid or invalid, and then you can check for its state from your setter.

or do I miss here something?
[ July 22, 2004: Message edited by: Ben Buchli ]
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something to play around with - but I don't understand "date range = 0181 -> 1220"
so I've just built in < 181 or > 1220 is invalid

Curse your sudden but inevitable betrayal! And this tiny ad too!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic