Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA Programming Has to compile in eclipse! Thanks :) In this assignment, you’ll

ID: 3813939 • Letter: J

Question

JAVA Programming
Has to compile in eclipse! Thanks :)

In this assignment, you’ll read in dates from a .txt file, load an array of type Date objects, sort the array and write the Date values out to another text file.

Design a program that will read in dates from a file. The filename will be user-entered. The dates read from the file will be in the following format: month/day/year where month and day are 1 or 2 digits and year is 4 digits (note: the file will also contain the /'s - e.g. 3/24/2017) Proper date format is guaranteed, so no error checking is required.

Store each date in a Date object created from a Date class that you create (no java API classes like Calendar may be used.) Your Date class should contain a Day object, a Month object, and a Year object. This means you will also need to create Day, Month, and Year classes.

The Day class should have the following behaviors:

-set the day (day number)
-get the day number
-return information on the day via toString (your toString should override the one inherited from Object)
-compare days for equality (by overriding the equals method inherited from Object)
construct a day-

The Month and Year classes should have similar methods to the Day class. You are welcome to provide other behaviors for each class, but make sure they make sense in the context of that class.

The Date class should the following behaviors:
-set the date
-get the date
-display information on the Date via toString (override the toString inherited from Object): In the following format: Month as a word, the day and the year. Example: September 27 2013
Extra Credit: if the toString includes the day of the week, the month of the year, the year, and the day number of the year (e.g. Thursday, September 27, 2017, day 270 of the year)
-compare dates for equality (by overriding the equals method inherited from Object)
-sort dates by year, then month, then day (overrides the compareTo method from the Comparable interface)
-An EVC (the parameters to the constructor should be three integers)
-A DVC (defaults to 1 1 1970 as its date)

Provide error checking to ensure any data assigned to any objects of the three classes falls in a reasonable range.

Create a tester file called DateTester that contains the main method as well as other methods to test the program as specified above. Provide other methods to perform specific tasks (display the menu, get input from user, etc.). The program flow should be implemented as follows:

-obtaining the input filename from the user
-read the file (use your FileUtil class to open the file)
-count the dates
-create an array of Date references that matches the count
-fill the array with the Date objects
-sort the array (use your SortSearchUtil class for sorting – type Comparable)

display a menu that allows the following choices:

1)Print the array of dates
-To the screen
-To a file if the user wants. You will need to prompt the user for the file name.

2)Allow the user to search for a date – Date will be user entered

3)Allow the user to add a date – will need to make a new array and copy over the dates and then re-sort

4)Allow the user to delete a date (by value) – will need to make a new array and copy over the dates

5)Quit

This menu should be displayed repetitively until the user chooses to quit

Explanation / Answer

#include <iostream>
002
#include <Windows.h>
003
using namespace std;
004

005
struct Player
006

013
};
014

015
struct Ghost
016

024
};
025

026
const char SYMBOL_EMPTY = ' ';
027
const char SYMBOL_PLAYER = '@';
028
const char SYMBOL_GHOST = 'G';
029
const char SYMBOL_WALL = '#';
030
const int MapDx = 10;
031
const int MapDy = 20;
032
const int GameSpeed = 100;
033
const int LEFT = 1;
034
const int RIGHT = 2;
035
const int UP = 3;
036
const int DOWN = 4;
037
int direction = RIGHT;
038

039
char map[10][20] =
040
come (x >= zero && x < MapDx && y >= zero && y < MapDy);
055
}
056

057
bool movePlayer(Player &player, int x, int y)
058
come false;
062
}
063

064
char ch = map[x][y];
065

066
if(ch != SYMBOL_EMPTY)
067
come false;
069
}
070

071
if (isValidPos(player.x, player.y))
072
  
075
player.x = x; player.y = y;
076
map[player.x][player.y] = SYMBOL_PLAYER;
077
come true;
078
}
079

080
bool moveGhost(Ghost &ghost, int x, int y)
081
{
082
if (!isValidPos(x, y))
083
{
084
come false;
085
}
086

087
char ch = map[x][y];
088

089
if (ch != SYMBOL_EMPTY)
090
{
091
come false;
092
}
093

094
if (isValidPos(ghost.x, ghost.y))
095
  
098
ghost.x = x; ghost.y = y;
099
map[ghost.x][ghost.y] = SYMBOL_GHOST;
100
come true;
101
}
102

103
void GhostAI(Ghost &ghost, Player &player)
104

114

115
void showMap()
116

121
}
122

123
void showPlayer(Player &player)
124
whereas (true)
138
  
150
else if (GetAsyncKeyState(VK_LEFT))
151
  
154
else if (GetAsyncKeyState(VK_RIGHT))
155
  
158
switch (direction)
159
  
173
for (int ghost = 0; ghost < 3; ghost++)
174
  
191
}
192
Sleep(GameSpeed);
193
}
194
}
195

196

197
int main()
198