473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

GFilde and Date class

Hi
please tell me the wrong in this code becaus it not compile with me
the question depend in other class that i do it before
and this class her:
public class GField
{
private int value;
private int minimum;
private int maximum;
private int defu;



public GField(int v,int m,int x,int def){
if (v>minimum && v<maximum) value=v;
else value=1;
value = v; minimum= m; maximum =x;
defu=def;
}

public int getV(){
return value;}
public int getM(){
return minimum;}
public int getX(){
return maximum;}

public void setV( int v){
if (v>minimum && v<maximum) value=v;
else value=1;
value = v;
}
public void setM( int m)
{
minimum= m;}
public void setX( int x)
{
maximum= x;}
but the other question is
2- Date class: this class has day, month, and year fields. All fields must be defined privates and all fields are of type GField defined above.
a. Provide a default constructor in which you set the date to 1/1/2000.
b. Provide a constructor that takes 3 integer parameters for the 3 fields.
c. Provide a constructor that takes 2 integer parameters for the day and month. The constructor should set the year to 2007.
d. Provide only getters for each field.
e. Provide the toString method such that it returns a string representation of the date in the form DD/Month/YYYY, e.g, (12/November/1990)
f. Write a method that returns the name of the month. For example, if the month is 3 it will returns "march".
g. Make sure that each field holds correct values. Specifically, month should be between 1 and 12 and day should be between 1 and 31. In case the user provided invalid day or month then you need to save a valid value instead as follows:
i. If the user provides a month which is not between 1 and 12, then set it with |(N % 12) + 1|.
ii. For days, if the user provides a day which is not between 1 and 31 then set it with the value | (N % 31) + 1|.
and i try to do it but it is not compile please tell me the wrong and this cod i wrote it.
public class Date1
{
private GField day;
private GField month;
private GField year;
public Date1(){
day=1;
month=1;
year=2000;
}
public Date1 ( GField D, GField M, GField Y){
if(M<=12 && M>=1) month=M;
else m=abs((N % 12) + 1) ;
if (D>=1 && D<=31) day=D;
else day=abs ((N % 31) + 1);
;

year= Y;
}
Date1( GField D, GField M){
day= D;
month=M;
year=2007;
}
GField getDay(){
return day;
}

GField getMonth(){
return month;
}

GField getYear(){
return year;
}
public String toString(){
return day + "/" + month + "/" + year;
}
public String getName(){
if (m==1) return "Jan";
if (m==2) return "november";
if (m==3) return " march";
if (m==4) return "Apr";
if (m==5) return "May";
if (m==6) return "JUN";
if (m==7) return "july";
if (m==8) return "Augest.";
if (m==9) return "Septemr";
if (m==10) return "october";
if (m==11) return "Nov";
else return "DEC";
}
}
Sorry if the question is too long and i hope who know the question explen to me the step of do this question
Nov 9 '07 #1
3 1465
JosAH
11,448 Expert 8TB
Hi
please tell me the wrong in this code becaus it not compile with me
And what does the compiler whine about then? The Java compiler does all its
best to whine as detailed as possible. Please show us what it whined about.

kind regards,

Jos
Nov 9 '07 #2
And what does the compiler whine about then? The Java compiler does all its
best to whine as detailed as possible. Please show us what it whined about.

kind regards,

Jos
thank you very much....sorry but i dont understand what you mean. I will explain to you my problem. when i compile the Date1 class ,it does not compile and her i use (Bluej) and it tell me that day=1; is wrong and the reason is( incompatible types-found (int) but expected GField). i hope that what you mean .and thank you again for your help^_^
Nov 10 '07 #3
r035198x
13,262 8TB
thank you very much....sorry but i dont understand what you mean. I will explain to you my problem. when i compile the Date1 class ,it does not compile and her i use (Bluej) and it tell me that day=1; is wrong and the reason is( incompatible types-found (int) but expected GField). i hope that what you mean .and thank you again for your help^_^
Like the compiler said, you declared day as a variable of type GFied and so you must store only GField type objects in it.
Nov 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ESPNSTI | last post by:
Hi, I'd like to be able to distinguish between a DateTime variable that is allowed to hold both date and time and a DateTime variable that is allowed to only hold a Date. The reason's for this...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
9
by: newtophp2000 | last post by:
I need to add the ability for the users to select a date on one of our web pages. The examples I was given by some users were in JavaScript. Is there a free date picker that I can use? I saw one...
3
by: RJA | last post by:
Hiyas, Using VS .net 2003. Setting up a Webservice that accepts 3rd party vendor designed XML requests and returns a filled XMLDocument with response data. Vendor XSDs were serialize into...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
1
by: aRTx | last post by:
<? /* Directory Listing Script - Version 2 ==================================== Script Author: Artani <artan_p@msn.com>. www.artxcenter.com REQUIREMENTS ============ This script requires...
1
osward
by: osward | last post by:
Hi everyone, Background 1. I have a table that consits 400+ rows of data and is growing by day. The table already has paging links at the bottom but I restricted to display rows of data only >=...
4
by: philly_bob | last post by:
In the sample program below, I want to send a random method to a class instance. In other words, I don't know which method to send until run-time. How can I send ch, which is my random choice, to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.