GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Oct-2006, 20:39
suriacute85 suriacute85 is offline
New Member
 
Join Date: Oct 2006
Location: malaysia
Posts: 1
suriacute85 is on a distinguished road
Exclamation

Please Help Me To Build My Calendar!!!


HELLO EVERYBODY...

I REALLY NEED YOUR HELP!!!!
I DON'T KNOW HOW TO BUILD A CALENDAR....
FOR ME, IT VERY COMPLEXS.. PLEASE HELP ME..
YOU CAN SEND THE SOLUTION TO MY EMAIL.
suriani_851204@yahoo.com.my

Object-Oriented Programming
MyCal: A Simple Calendar Application

For this project, you are required to build a Java application called MyCal. MyCal is a simple calendar application that has the following features:

1. Create an empty calendar
A user must create an empty calendar for a particular year before any appointment can be made for that year. For example, to store appointments for the year 2006, the user will first need to request MyCal to create an empty calendar for 2006.
Output O1 shows the opening screen for MyCal. In this screen, the user is asked whether to create a new (empty) calendar or to open an existing one.
Output O2 shows the screen displayed when the user chooses to create a new calendar.

2. Display the current calendar
MyCal is able to display all dates for each month in the current calendar. There are three basic views through which a user may view the calendar:
a. Year View

This view displays the total number of appointments for each month in the current calendar. Refer output O3.
b. Month View

This view displays the total number of appointments for a particular month in the current calendar. Refer output O5.
c. Day View

This view displays a list of appointments for a particular day and month in the current calendar. Refer output O6.

3. Add/Delete appointments
A MyCal user can add an appointment in either the Year View or the Day View (refer outputs O4 and O7). Appointments can only be deleted in the Day View (refer output O.

4. Check appointment clashes
When making a new appointment, MyCal will check if there any time clashes between that appointment and existing appointments. If a time clash occurs, MyCal will display a warning and asks the user for confirmation (refer output O9).

5. Save calendar
MyCal will automatically save the current calendar when the user exits the program (refer output O10).

6. Open an existing calendar
A user can choose to open a previously saved calendar in MyCal‘s opening screen (refer output O11).
Design
Based on the description given above, you are required to construct MyCal using object-oriented programming and the Java language. You will be provided with a skeletal Java program next week which you must use as a basis for constructing your program. Further instructions will also be given in that week.
Implementation
The user interface for your program must be text-based. Thus, you are not allowed to use any GUI (Graphical User Interface) components such as those provided in the AWT and Swing libraries. The outputs in the appendix are only suggestions. Your program need not follow the format exactly as long as it is consistent with the description given above.
Deadline
The deadline for submitting your project is on 11 SEPTEMBER 2006. Late submissions will be strictly rejected (we really mean it!).


APPENDIX: SAMPLE OUTPUT
• O1: MyCal’s Opening Screen
W E L C O M E T O M y C a l
=======================

<<What do you want to do?>>
[1]. Create a new calendar
[2]. Open a calendar
[0]. Exit MyCal
Selection:
• O2: Creating a New Calendar
W E L C O M E T O M y C a l
=======================

<<What do you want to do?>>
[1]. Create a new calendar
[2]. Open a calendar
[0]. Exit MyCal
Selection: 1
Enter year: 2006
Calendar 2006 created
• O3: Year View
=============
Calendar 2006
=============
1. JAN (0) 2. FEB (0) 3. MAC (0) 4. APR (0)
5. MAY (0) 6. JUN (0) 7. JUL (0) 8. AUG (0)
9. SEP (0) 10. OCT (0 11. NOV (0) 12. DEC (0)

<<What do you want to do?>>
[1 - 12]. Choose a month
[13]. Add an appointment
[0]. Exit MyCal
Selection:
• O4: Adding a New Appointment in Year View
=============
Calendar 2006
=============
1. JAN (0) 2. FEB (0) 3. MAC (0) 4. APR (0)
5. MAY (0) 6. JUN (0) 7. JUL (0) 8. AUG (0)
9. SEP (0) 10. OCT (0 11. NOV (0) 12. DEC (0)

<<What do you want to do?>>
[1 - 12]. Choose a month
[13]. Add an appointment
[0]. Exit MyCal
Selection: 13
Enter month: 2
Enter day: 3
Enter hr: 13
Enter mins: 30
Enter description: TK2933 Lecture
• O5: Month View
=============
FEB 2006
=============
1. (0) 2. (0) 3. (1) 4. (0) 5. (0) 6. (0) 7. (0)
8. (0) 9. (0) 10. (0) 11. (0) 12. (0) 13. (0) 14. (0)
15. (0) 16. (0) 17. (0) 18. (0) 19. (0) 20. (0) 21. (0)
22. (0) 23. (0) 24. (0) 25. (0) 26. (0) 27. (0) 28. (0)


<<What do you want to do?>>
[1 - 31]. Choose a day
[0]. Exit
Selection:
• O6: Day View
=============
3 FEB 2006
=============
0. 13:30 TK2933 Lecture

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection:
• O7: Adding a New Appointment in Day View
=============
3 FEB 2006
=============
0. 13:30 TK2933 Lecture

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection: 1
Enter hour: 15
Enter min: 00
Enter description: Go to library
• O8: Deleting an Appointment in Day View
=============
3 FEB 2006
=============
0. 13:30 TK2933 Lecture
1. 15:00 Go to library

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection: 2


=============
3 FEB 2006
=============
0. 13:30 TK2933 Lecture
1. 15:00 Go to library
Select appointment to delete: 0

=============
3 FEB 2006
=============
0. 15:00 Go to library

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection:
• O9: Time Clash
=============
3 FEB 2006
=============
0. 15:00 Go to library

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection: 1
Enter hour: 15
Enter min: 00
Enter description: Call Hassan
TIME CLASH WARNING: Go to library
Confirm (y/n)? y

=============
3 FEB 2006
=============
0. 15:00 Go to library
1. 15:00 Call Hassan

<<What do you want to do?>>
[1]. Make a new appointment
[2]. Delete an appointment
[0]. Exit
Selection:
• O10: Automatic Saving
=============
Calendar 2006
=============
1. JAN (3) 2. FEB (4) 3. MAC (1) 4. APR (0)
5. MAY (0) 6. JUN (0) 7. JUL (0) 8. AUG (0)
9. SEP (0) 10. OCT (0 11. NOV (0) 12. DEC (0)

<<What do you want to do?>>
[1 - 12]. Choose a month
[13]. Add an appointment
[0]. Exit MyCal
Selection:0
Saving the current calendar…
Thank you for using MyCal!
• O11: Opening a Calendar
W E L C O M E T O M y C a l
=======================

<<What do you want to do?>>
[1]. Create a new calendar
[2]. Open a calendar
[0]. Exit MyCal
Selection: 2
Enter year: 2006
Calendar 2006 successfully opened.
=============
Calendar 2006
=============
1. JAN (3) 2. FEB (4) 3. MAC (1) 4. APR (0)
5. MAY (0) 6. JUN (0) 7. JUL (0) 8. AUG (0)
9. SEP (0) 10. OCT (0 11. NOV (0) 12. DEC (0)

<<What do you want to do?>>
[1 - 12]. Choose a month
[13]. Add an appointment
[0]. Exit MyCal
Selection:



THIS IS THE DESIGN REQUIREMENT :

TK2933 Object-Oriented Programming
Group Project
Project 1 Design Requirements
Required Classes
Your program must involve the following classes:
i. MyCal class
A MyCal object represents the calendar application. The main() method must be defined in the MyCal class.. The object performs the necessary initialization when the application starts its execution. It is responsible for displaying the opening menu through which the user specifies whether to create a new calendar or open an existing one. When the user has specified the calendar to work on, the object passes control to a YearViewer object.
ii. YearViewer class
A YearViewer object represents the “year view”. It is responsible for displaying the number of appointments for each month of the calendar. It displays the “year view” menu through which the user may request to add a new appointment or enter the “month view” for a particular month. If the user wishes to enter the “month view” for a particular month, the object passes control to a MonthViewer object.
iii. MonthViewer class
A MonthViewer object represents the “month view” for a particular month. It is responsible for displaying a summary of the number of appointments for each day of the month. It displays the “month view” menu through which the user may request to enter the “day view” for a particular day of the month. To enter the “day view”, the object needs to pass control to a DayViewer object.
iv. DayViewer class
A DayViewer object represents the “day view” for a particular day of a particular month. It is responsible for displaying a list of appointments for that day. It displays the “day view” menu through which the user may request to add a new appointment or delete an existing appointment for the day.
v. Calendar class
A Calendar object represents a calendar for a particular year. It manages a collection of Month objects; a Month object for each month of the year.
vi. Month class
A Month object represents a particular month. This object manages a collection of Day objects; a Day object for each day of the month.
vii. Day class
A Day object represents a particular day. This object manages a collection of Appointment objects; an Appointment object for each appoinment for the day.
viii. Appointment class
An Appointment object represents an appointment. This object contains information about the appointment.
CalendarReader and CalendarWriter
You will be provided with the CalendarReader and CalendarWriter classes to enable you to save and open calendars.
i. CalendarReader
This class has a method called read() for reading a calendar from a file:
public Calendar read(String fname);
where fname is the name of the file from which a calendar will be read. The method returns a Calendar object representing that calendar. The following example reads a calendar from a file named “2006”:
Calendar cal = (new CalendarReader()).read("2006");
ii. CalendarWriter
This class has a method called save() for saving a calendar to a file:
public void save(String fname, Calendar cal);
where cal refers to the Calendar object to be saved and fname is the name of the file. The following example saves a calendar to a file named “2006”:
(new CalendarWriter()).write("2006", cal);
Skeletal Program
The skeletal program which will become the basis for your program is provided below (and can be downloaded from the portal). You will need to flesh out the class definitions (by defining the appropriate attributes and methods) so that the program runs as expected. You are not allowed to change the structure of the program although you may define additional classes and methods.
Stages of Development
You are encouraged to develop your program in stages as suggested below. Your program should be tested thoroughly at each stage before moving on to the following stage.
Stage 1:
• Able to correctly display an empty calendar in “year view”, “month view” and “day view”
Stage 2:
• Achieved Stage 0
• Able to add appointments in “day view”
Stage 3:
• Achieved Stage 2
• Able to delete appointments in “day view”
Stage 4:
• Achieved Stage 3
• Able to save calendar
Stage 5:
• Achieved Stage 4
• Able to open an existing calendar
Stage 6:
• Achieved Stage 5
• Able to add appointments in “year view”
Stage 7:
• Achieved Stage 6
• Able to check appointment clashes

The Skeletal Program
CPP / C++ / C Code:
class MyCal {
	public void run() {
		Calendar calendar = getCalendar();
		if (calendar != null) {
				/* ENTER YEAR VIEW */
			(new YearViewer(calendar)).activate();

				/* AUTOMATICALLY SAVE CALENDAR */
			System.out.println("Automatically saves calendar");
		}
		System.out.println("Thank you for using MyCal");
	}
	private Calendar getCalendar() {
		int selection = getMenuSelection();
		if (selection == 0) 
			return null;
		else {
			return (new Calendar(2006));
		}
	}
	private int getMenuSelection() {
		for (int i=0; i < 23; i++)
			System.out.println();
		System.out.println("W E L C O M E  T O  M y C a l");
		System.out.println("=============================");
		System.out.println("\n<<What do you want to do?>>");
		System.out.println("[1]. Create a new calendar");
		System.out.println("[2]. Open a calendar");
		System.out.println("[0]. Exit");
		int selection;
		do {
			System.out.print("Enter selection: ");
			selection = (new Scanner(System.in)).nextInt();
			if (0 <= selection  &&  selection <= 2)
				break;
			System.out.println("Error: value must be >= 0 and <= 2");
		} while (true);
		return selection;
	}
	public static void main(String[] args) {
		(new MyCal()).run();
	}
}

class YearViewer {
	private Calendar cal;
	public YearViewer(Calendar c) {
		cal = c;
	}
	public void activate() {
		int selection;
		do {
			for (int i=0; i < 23; i++)
				System.out.println();
				
				/* Display year view */
			System.out.println("YEAR VIEW");

				/* Display menu and get selection */
			System.out.println("\n<<YEAR VIEW MENU>>");
			System.out.println("Selection: ");
			selection = (new Scanner(System.in)).nextInt();

			if (selection == 0) 
				break;
			else
				System.out.println("Enter month view");
		} while (true);
	}
}

class MonthViewer {
	public void activate() {
		int selection; 
		do {
			for (int i=0; i < 23; i++)
				System.out.println();
				
				/* Display month view */
			System.out.println("MONTH VIEW");

				/* Display menu and get selection */
			System.out.println("\n<<MONTH VIEW MENU>>");
			System.out.println("Selection: ");
			selection = (new Scanner(System.in)).nextInt();

			if (selection == 0)
				break;
			else
				System.out.println("Enter day view");
		} while (true);		
	}
}
class DayViewer {
	public void activate() {
		int selection;
		do {
			for (int i=0; i < 23; i++)
				System.out.println();
				
				/* Display day view */
			System.out.println("DAY VIEW");

				/* Display menu and get selection */
			System.out.println("\n<<DAY VIEW MENU>>");
			System.out.println("Selection: ");
			selection = (new Scanner(System.in)).nextInt();

			if (selection == 0)
				break;
			else if (selection == 1)
				; /* MAKE NEW APPOINTMENT */
			else 
				; /* DELETE AN APPOINTMENT */
		} while (true);		
	}
}
class Calendar {
	private Month[] months = new Month[12];
	private int year;
	public Calendar(int year) {
		this.year = year;
		for (int mth=0; mth < 12; mth++)
			months[mth] = new Month(mth, year);
	}
	public boolean addAppointment(int day, int mth, int hr, int min, String description) {
			/* REQUEST MONTH OBJECT TO ADD AN APPOINTMENT */
		return months[mth].addAppointment(day, hr, min, description);
	}
	public int getYear() {
		return year;
	}
	public Month getMonth(int i) {
		return months[i];
	}
	public boolean hasClash(int mth, int day, int hr, int min) {
			/* REQUEST MONTH OBJECT TO CHECK CLASH */
		return months[mth].hasClash(day, hr, min);
	}
}
class Month {
	private Day[] days;
	private int mth;
	public Month(int m, int yr) {
		mth = m;
	}
	public boolean addAppointment(int day, int hr, int min, String description) {
		/* Returns true if the operation is successful; returns false, otherwise */	
	}
	public boolean deleteAppointment(int day, int idx) {
		/* Returns true if the operation is successful; returns false, otherwise */	
	}
	public int getNumAppointments() {
		/* Returns the total number of appointments in the month */
	}
	public int getNumDays() {
		/* Returns the number of days in the month */
	}
	public Day getDay(int n) {
		/* Returns the Day object for nth day of the month */
	}
	public boolean hasClash(int n, int hr, int min) {
		/* Returns true if there are appointments on the nth day at hr:min */
	}
}

class Day {
	private Appointment[] appts;
	private int day;
	public Day(int d) {
		day = d;
	}
	public boolean addAppointment(int hr, int min, String description) {
		/* Returns true if operation is successful; returns false, otherwise */
	}
	public int getNumAppointments() {
		/* Returns the number of appointments in the day */
	}
	public int getDay() {
		/* Returns the value of the 'day' attribute */
	}
	public Appointment getAppointment(int n) {
		/* Returns the Appointment object for the nth appointment */
	}
	public boolean deleteAppointment(int n) {
		/* Delete the nth appointment.  Returns true if successful; returns false, otherwise. */
	}
	public boolean hasClash(int hr, int min) {
		/* Returns true if there are appointments at hr:min */
	}
}
class Appointment {
	private int hr, min;
	private String desc;
	public Appointment(int h, int m, String d) {
		hr = h;
		min = m;
		desc = d;
	}
	public int getHour() {
		return hr;
	}
	public int getMinutes() {
		return min;
	}
	public String getDesc() {
		return desc;
	}
}
Attached Files
File Type: doc Design requirements.doc (50.5 KB, 32 views)
File Type: doc project 1 desc.doc (53.0 KB, 33 views)
File Type: zip Skeletal program.zip (5.5 KB, 44 views)
Last edited by LuciWiz : 06-Oct-2006 at 01:32. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogI?m Home by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My new PC build. theotherguy Computer Hardware Forum 4 05-Nov-2006 22:24
VB Calendar application for smart device problem adie_w .NET Forum 0 15-Feb-2006 05:13
Small help with this build error!! Krc784 C++ Forum 3 11-Nov-2004 14:05
I plan to build a computer.... jjansen Computer Hardware Forum 5 14-Apr-2004 06:55
Help with calendar program mike3340 C++ Forum 0 18-Nov-2003 21:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:03.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.