-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAss9_CaseStudy
More file actions
143 lines (132 loc) · 4.96 KB
/
Ass9_CaseStudy
File metadata and controls
143 lines (132 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
class TeamMember{
private String name;
private String email;
public TeamMember(String name,String email){
this.name=name;
this.email=email;
}
public String toString(){
return "TeamMember[name=" +name + ",email=" + email + "]";
}
}
class Task{
private String name;
private String description;
private TeamMember assignee;
private Date dueDate;
private String status;
private int priority;
public Task(String name,String description,TeamMember assignee, Date dueDate,String statu
this.name=name;
this.description=description;
this.assignee=assignee;
this.dueDate=dueDate;
this.status=status;
this.priority=priority;
}
public String toString(){
return "Task[name=" + name + ",status=" + status +",priority=" + priority + "]";
}
}
class Project {
private String name;
private String description;
private Date startDate;
private Date endDate;
private String owner;
private List<Task> tasks;
public Project(String name,String description,Date startDate,Date endDate,String owner){
this.name=name;
this.description=description;
this.startDate=startDate;
this.endDate=endDate;
this.owner=owner;
this.tasks= new ArrayList<>();
}
public void addTask(Task task){
tasks.add(task);
}
public List<Task> getTasks(){
return tasks;
}
public String toString() {
return "Project[name=" +name + ",description=" + description + "]";
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
List<TeamMember> teamMembers = new ArrayList<>();
for(int i=1;i<=5;i++){
System.out.println("Enter details for Team Members" + i + ":");
System.out.print("Name: ");
String name= sc.nextLine();
System.out.print("Email: ");
String email= sc.nextLine();
teamMembers.add(new TeamMember(name, email));
}
Project project = null;
try {
System.out.println("Enter details for Project:");
System.out.print("Name: ");
String projectName = sc.nextLine();
System.out.print("Description: ");
String projectDescription =sc.nextLine();
System.out.print("Start Date(yyyy-mm-dd): ");
Date startDate = java.sql.Date.valueOf(sc.nextLine());
System.out.print("End Date(yyyy-mm-dd): ");
Date endDate = java.sql.Date.valueOf(sc.nextLine());
System.out.print("Owner: ");
String projectOwner = sc.nextLine();
project = new Project (projectName, projectDescription, startDate, endDate, proje
}
catch(Exception e){
System.out.println("Error occured while creating the project: " + e.getMessage())
}
for(int i=1;i<=5;i++){
if(project ==null){
System.out.println("Project is null.Please create project file first.");
break;
}
try{
System.out.println("Enter details for Task " + i + ":");
System.out.print("Name: ");
String taskName = sc.nextLine();
System.out.print("Description: ");
String taskDescription = sc.nextLine();
System.out.print("Assignee(1-5 for Team Member 1-5); ");
int assigneeIndex= sc.nextInt() - 1;
if(assigneeIndex <0 || assigneeIndex >= teamMembers.size()){
throw new IndexOutOfBoundsException("Assignee index out of bounds. ");
}
TeamMember assignee = teamMembers.get(assigneeIndex);
sc.nextLine();
System.out.print("Due Date (yyyy-mm-dd): ");
Date taskDueDate = java.sql.Date.valueOf(sc.nextLine());
System.out.print("Status: ");
String taskStatus = sc.nextLine();
System.out.print("Priority: ");
int taskPriority = sc.nextInt();
sc.nextLine();
Task task = new Task(taskName, taskDescription, assignee, taskDueDate , taskS
project.addTask(task);
}
catch(Exception e){
System.out.println("Error occured while adding task: " + e.getMessage());
}
}
if(project !=null){
System.out.println("\nProject Details:");
System.out.println(project);
System.out.println("\nTasks:");
for(Task task : project.getTasks()){
System.out.println(task);
}
}
sc.close();
}
}