-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject3.java
More file actions
82 lines (73 loc) · 2.19 KB
/
Copy pathProject3.java
File metadata and controls
82 lines (73 loc) · 2.19 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
package proj3;
import java.util.Scanner;
/**
* <p>Title: Project 3. A scheduling App </p>
* <p>Description: The App will let the volunteer know whether
* they have been scheduled to work on an upcoming collection day
</p>
* @author Olena Fedochynska
*/
public class Project3 {
public static void main(String[] args) {
// declares and instantiates a CollectionEvent object
CollectionEvent event = new CollectionEvent('S', 900, 1400);
Scanner scnr = new Scanner (System.in);
//ask volunteer for available day
System.out.print("Enter the day you are available (M, T, W, R, F, S, U): ");
char volAvailable = scnr.next().charAt(0);
// check if in volunteer's available day there is event
boolean dayAvailable = event.sameDay(volAvailable);
if (dayAvailable == true)
{
//Ask for time
System.out.print("Enter your available start time (military format): ");
int volStart = scnr.nextInt();
System.out.print("Enter your available end time (military format): ");
int endStart = scnr.nextInt();
//check volunteer's time equal event time
boolean timeAvailable = event.scheduleVolunteer(volStart, endStart);
if (timeAvailable == true)
{
System.out.println("Thank you! You are scheduled to volunteer on \n\n" + event.toString());
}
else
{
System.out.println("Sorry, we do not need volunteers at those times.\n\n" + event.toString());
}
}
else
{
System.out.println("Sorry, this is not an available collection day.\n\n" + event.toString());
}
scnr.close();
/*
* Testing:
* 1. Input: 'T' → Expected:
* Sorry, this is not an available collection day.
*
* Collection day:
* Collection occurs on: S
* Start time: 900
* End time: 1400
* Number of volunteers: 0
*
* 2. Input: 'S', 0800, 1100 → Expected: "
*Sorry, we do not need volunteers at those times.
*
*Collection day:
*Collection occurs on: S
*Start time: 900
*End time: 1400
*Number of volunteers: 0
*
* 3. Input: 'S', 0900, 1400 → Expected:
* Thank you! You are scheduled.
*
* Collection day:
* Collection occurs on: S
* Start time: 900
* End time: 1400
* Number of volunteers: 1
*/
}
}