Skip to content

Commit

Permalink
event calender flipkart
Browse files Browse the repository at this point in the history
  • Loading branch information
gowtkum committed Aug 14, 2021
1 parent c77df60 commit da4f515
Show file tree
Hide file tree
Showing 35 changed files with 622 additions and 0 deletions.
Binary file added Event_calendar_flipkart/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions Event_calendar_flipkart/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Event_calendar_flipkart/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Event_calendar_flipkart/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions Event_calendar_flipkart/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Event_calendar_flipkart/Event Calendar.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions Event_calendar_flipkart/mcoding.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Event_calendar_flipkart/src/.DS_Store
Binary file not shown.
Binary file added Event_calendar_flipkart/src/com/.DS_Store
Binary file not shown.
Binary file added Event_calendar_flipkart/src/com/sss/.DS_Store
Binary file not shown.
Binary file not shown.
53 changes: 53 additions & 0 deletions Event_calendar_flipkart/src/com/sss/mcoding/Driver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.sss.mcoding;

import com.sss.mcoding.app.EventCalendar;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;

public class Driver {



public static void main(String args[]) throws IOException, ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
EventCalendar eventCalendar = new EventCalendar();

eventCalendar.createUser("A", dateFormat.parse("2021-07-07 9:00:00"), dateFormat.parse("2021-07-07 21:00:00"));
eventCalendar.createUser("B", dateFormat.parse("2021-07-07 9:00:00"), dateFormat.parse("2021-07-07 21:00:00"));
eventCalendar.createUser("C", dateFormat.parse("2021-07-07 9:00:00"), dateFormat.parse("2021-07-07 21:00:00"));

eventCalendar.createTeam("T1", Arrays.asList(new String[]{"A", "B"}));


eventCalendar.createEvent("E1", Arrays.asList("C"), Arrays.asList("T1"), 1,
dateFormat.parse("2021-07-07 13:00:00"), dateFormat.parse("2021-07-07 15:00:00"));

// eventCalendar.createEvent("E2", Collections.emptyList(), Arrays.asList("T1"), 1,
// dateFormat.parse("2021-07-07 13:00:00"), dateFormat.parse("2021-07-07 15:00:00"));


eventCalendar.printUser("A");
eventCalendar.printUser("B");
eventCalendar.printUser("C");

eventCalendar.createEvent("E1", Arrays.asList("C"), Arrays.asList("T1"), 1,
dateFormat.parse("2021-07-07 13:00:00"), dateFormat.parse("2021-07-07 15:00:00"));


// eventCalendar.createEvent("E3", Collections.emptyList(), Arrays.asList("T1"), 1,
// dateFormat.parse("2021-07-07 11:00:00"), dateFormat.parse("2021-07-07 13:00:00"));
//
// eventCalendar.createEvent("E4", Collections.emptyList(), Arrays.asList("T1"), 2,
// dateFormat.parse("2021-07-07 15:00:00"), dateFormat.parse("2021-07-07 16:00:00"));
//
// eventCalendar.createEvent("E5", Collections.emptyList(), Arrays.asList("T1"), 3,
// dateFormat.parse("2021-07-07 19:00:00"), dateFormat.parse("2021-07-07 20:00:00"));

}

}
48 changes: 48 additions & 0 deletions Event_calendar_flipkart/src/com/sss/mcoding/app/EventCalendar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.sss.mcoding.app;

import com.sss.mcoding.managers.EventManager;
import com.sss.mcoding.managers.TeamManager;
import com.sss.mcoding.managers.UserManager;
import com.sss.mcoding.models.Event;
import com.sss.mcoding.models.TimeSlot;
import com.sss.mcoding.models.User;

import java.util.Date;
import java.util.List;

public class EventCalendar {

private UserManager userManager;
private TeamManager teamManager;
private EventManager eventManager;

public EventCalendar() {
userManager = new UserManager();
teamManager = new TeamManager(userManager);
eventManager = new EventManager(userManager, teamManager);
}

public void createUser(String name, Date startTime, Date endTime) {
TimeSlot workingHours = new TimeSlot(startTime, endTime);
userManager.createUser(name, workingHours);
}

public void createTeam(String name, List<String> userNames) {
teamManager.createTeam(name, userNames);
}

public void createEvent(String eventName, List<String> userNames, List<String> teamNames, int rep, Date startTime, Date endTime) {
eventManager.createEvent(eventName, userNames, teamNames, rep, startTime, endTime);
}

public void printUser(String userId) {
User user = userManager.getUser(userId);

for (Event event : user.getEvents()) {
System.out.println(userId + " - "+ event.getName() + " - " + event.getTimeSlot().getStartTime() + " - " + event.getTimeSlot().getEndTime());
}

}


}
30 changes: 30 additions & 0 deletions Event_calendar_flipkart/src/com/sss/mcoding/dao/TeamDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.sss.mcoding.dao;

import com.sss.mcoding.models.Team;
import com.sss.mcoding.models.TimeSlot;
import com.sss.mcoding.models.User;

import java.util.HashMap;
import java.util.Map;

public class TeamDao {
private Map<String, Team> teamMap;

public TeamDao() {
teamMap = new HashMap<>();
}

public void createTeam(Team team) {
if (teamMap.containsKey(team.getName())) {
throw new RuntimeException("Team exists with same name " + team.getName());
}
teamMap.put(team.getName(), team);
}

public Team getTeam(String teamName) {
if (!teamMap.containsKey(teamName)) {
throw new RuntimeException("Team not found with name " + teamName);
}
return teamMap.get(teamName);
}
}
39 changes: 39 additions & 0 deletions Event_calendar_flipkart/src/com/sss/mcoding/dao/UserDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.sss.mcoding.dao;

import com.sss.mcoding.models.Event;
import com.sss.mcoding.models.Team;
import com.sss.mcoding.models.TimeSlot;
import com.sss.mcoding.models.User;

import java.util.HashMap;
import java.util.Map;

public class UserDao {
private Map<String, User> userMap;

public UserDao() {
userMap = new HashMap<>();
}

public void addUser(User user) {
if (userMap.containsKey(user.getName())) {
throw new RuntimeException("User already exists with same name " + user.getName());
}
userMap.put(user.getName(), user);
}

public User getUser(String userName) {
if (!userMap.containsKey(userName)) {
throw new RuntimeException("User not found with name " + userName);
}
return userMap.get(userName);
}

public void setTeam(User user, Team team) {
user.setTeam(team);
}

public void addEvent(User user, Event event) {
user.getEvents().add(event);
}
}
Loading

0 comments on commit da4f515

Please sign in to comment.