Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
66 lines (52 loc) · 1.49 KB

File metadata and controls

66 lines (52 loc) · 1.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package park;
import java.util.Calendar;
import java.util.Date;
/*
* Req3: Any registered client can book a valid parking space (i.e., currently not occupied or booked by other
* users) after login to the system, the parking rates for different types of users are different, i.e., 5$, 8$, 10$, and
* 15$ for students, faculty members, non-faculty staffs, and visitors per hour respectively.
* **/
//Component interface
interface ParkingRate {
public int calculateRate(int hours);
}
//Concrete component classes
class StudentRate implements ParkingRate {
public int calculateRate(int hours) {
return hours * 5;
}
}
class FacultyRate implements ParkingRate {
public int calculateRate(int hours) {
return hours * 8;
}
}
class StaffRate implements ParkingRate {
public int calculateRate(int hours) {
return hours * 10;
}
}
class VisitorRate implements ParkingRate {
public int calculateRate(int hours) {
return hours * 15;
}
}
//Decorator class
abstract class ParkingRateDecorator{
protected ParkingRate rate;
public ParkingRateDecorator(ParkingRate rate) {
this.rate = rate;
}
public int calculateRate(int hours) {
return rate.calculateRate(hours);
}
}
//Concrete decorator classes
class EarlyBirdDecorator extends ParkingRateDecorator {
public EarlyBirdDecorator(ParkingRate rate) {
super(rate);
}
public int calculateRate(int hours) {
return rate.calculateRate(hours);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.