Skip to content

Added date function and test #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions PROBLEMS/dateFunction/Date.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

public class Date {

int month, day, year;

public Date () {
month = 1;
day = 1;
year = 2000;
}


public Date(int givenMonth, int givenDay, int givenYear ) {
month = givenMonth;
day = givenDay;
year = givenYear;

}


public int getMonth() {
return month;

}


public int getDay() {
return day;

}



public int getYear() {
return year;

}



public void setMonth(int monthG) {

month = monthG;
}


public void setDay(int dayG) {
day = dayG;
}




public void setYear(int yearG) {

year = yearG;
}



@Override
public String toString() {
return month + "/" + day + "/" + year ;

}


public void printDate() {
System.out.println (month + "/" + day + "/" + year) ;
}



}
34 changes: 34 additions & 0 deletions PROBLEMS/dateFunction/DateTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@




public class DateTest {
public static void main(String[] args) {
System.out.println(" ");

Date d1 = new Date();
Date d2 = new Date(06,10,1999);
Date d3 = new Date(02, 23,2002);


System.out.println(d1.getMonth());
System.out.println(d2.getDay());
System.out.println(d3.getYear());

System.out.println();
d1.printDate();
d2.printDate();
d3.printDate();


System.out.println(d1.toString());
System.out.println(d2.toString());
System.out.println(d3.toString());





}

}