473,670 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GFilde and Date class

16 New Member
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 1488
JosAH
11,448 Recognized Expert MVP
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
miss time
16 New Member
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 MVP
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
9830
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 is that I'd like to store DateTime variables that are allowed to hold date and time as UTC in the database. However I'd to store DateTime variables that are only allowed to hold a date (like a birthdate) not as UTC (since adding a +6h time offset...
6
4181
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." Is there a way to make sure that the date header is sent over or a way to work around this exception? Here's a sample of the code:
9
2246
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 at http://webfx.eae.net but it does not seem to be free. Thanks!
3
5992
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 class objects to be used in the program. EX: Used xsd.exe to turn VendorA_Request.XSD into VendorA_Request.cs EX: Used xsd.exe to turn VendorA_Response.XSD into VendorA_Response.cs
10
4777
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 value for the parameter of an SqlCommand for inserting the xml document in a column of a table where the column is typed to be of the same xml schema. This all sounds simple, but SQL Server REQUIRES the timezone to be specified for date values....
2
2706
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 up an arrival time and a departure time for the script. This is using AJAX (which I am such a newbee @) from my earlier post http://www.thescripts.com/forum/threadnav583131-1-10.html Any help is greatly appreciated. <? $output = '';
1
4138
by: aRTx | last post by:
<? /* Directory Listing Script - Version 2 ==================================== Script Author: Artani <artan_p@msn.com>. www.artxcenter.com REQUIREMENTS ============ This script requires PHP and GD2 if you wish to use the
1
2615
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 >= current date. Otherwise, user have to waste time to page up the pages to find the current date 2. I got a script of simple calendar from the web that use mktime() to create links on the calendar Task I need to let user view data earlier than...
4
1492
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 the myclass instance? Thanks, Bob= ####
0
8471
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8388
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8817
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7423
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5687
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1799
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.