Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-2007, 09:24 PM
sthenri sthenri is offline
Newbie
 
Join Date: Oct 2007
Posts: 15
Rep Power: 5
sthenri is on a distinguished road
Default Classes

I thank you for any help you can give with this exercise.
I am reading about user-defined classes and ADT's for the first time.

This exercise asks me to create a UML diagram for a class called MyDate that contains data memebers and a constructor that meet the criteria for the following list. This class is used to initialize instance variables.

The nonstatic integer data members named month, day, and year should be private members so that they cannot be directly manipulated outside of the class.

The nonstatic Boolean data member named good should be a public member so that it can be accessed outside of the class.

The constructor MyDate() should assign to the member variables the values 1 to month, 1 to day, 2006 to year, and the value true to good.

Would the constructor look like this?
+MyDate()
+MyDate(1, 1, 2006, true)

So far I have
______________
MyDate
______________
-month: int
-day: int
-year: int
+good: int
_______________
+MyDate()
+MyDate(1,1,2006,true)

Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-21-2007, 01:56 AM
domestic's Avatar   
domestic domestic is offline
Learning Programmer
 
Join Date: Mar 2007
Location: SCOTLAND!
Age: 20
Posts: 39
Rep Power: 7
domestic is on a distinguished road
Default

Basically, YES. Remove the plus symbol and it should work.

I'm not 100% sure what your wanting to do but heres my thoughts. Note, the code is examples only and would need minor adapting to your situation.


Java Code:
  1. //assign to a variable: date
  2. date = MyDate(1,1,2006,true);
  3.  
  4.  
  5. //check a date using MyDate method
  6. if(date == MyDate(1,1,2006,true){
  7.     return true;
  8. else
  9.     return false;
  10. }
  11.  
  12. //NB using return will end the method are return to parent method
  13.  


As you should be able to see, the basic answer is yes, depending on how you want to use it.

Hope this helps!

Domestic
__________________
.


Programming Languages: Java, VB6, VB2005 (.NET2)
Web Languages: HTML, CSS, JS

Website: http://abdn.ac.uk/~u41am6

Opportunity is missed by most people because it is dressed in overalls and looks like work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-06-2007, 08:16 AM
sthenri sthenri is offline
Newbie
 
Join Date: Oct 2007
Posts: 15
Rep Power: 5
sthenri is on a distinguished road
Default Thank You

Thank You
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue writing to file: pointer to a class which contains pointers to other classes Sheemer C and C++ 0 08-21-2007 02:17 AM
Abstract Classes CyberByte C and C++ 1 02-21-2007 07:22 PM
Data and Classes Sionofdarkness Java Help 5 08-23-2006 10:18 PM
Classes, Methods, and Objects Sionofdarkness Java Help 6 08-21-2006 01:55 PM
understanding classes Chan C# Programming 3 07-17-2006 01:19 AM


All times are GMT -5. The time now is 03:03 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads