-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
91 lines (66 loc) · 3.75 KB
/
Project.java
File metadata and controls
91 lines (66 loc) · 3.75 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
//Software Engineering Task 24 - Capstone Project III.
// Importing java classes for use in the program.
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
// NewProject is a subclass that inherits methods from the InputChecks superclass.
// This class contains variables and a method for adding a new project object to the Poised Management System.
// The PoisedMenu class, which runs the main program, calls on methods from this class to add new projects.
public class Project extends InputChecks {
// Listing variable attributes for the 'NewProject' class.
private int projectNumber;
private String projectName;
private String buildingType;
private String address;
private String erfNumber;
private double totalFee;
private double amountPaid;
private String deadline;
private String Completion;
private String Status;
// The addProject method is used to add a new project object to the Poised Management System.
// It prompts the user to enter information related to project details which is then verified with methods from
// the superclass InputChecks, and stored in variables related to the project object.
// It displays the new project object created and writes the project info to the CurrentProjects.txt file.
public void addProject() {
// Completion and Status variables set to negative as this is a newly added project.
Completion = "None";
Status = "Not finalised";
// User prompted for input regarding project information.
System.out.println("\nPlease enter the project number: ");
projectNumber = intCheck("project number");
System.out.println("Please enter the project name: ");
projectName = stringCheck("project name");
System.out.println("Please enter the building type: ");
buildingType = stringCheck("building type");
System.out.println("Please enter the physical address for the project: ");
address = stringCheck("physical address");
System.out.println("Please enter the ERF number: ");
erfNumber = stringCheck("ERF number");
System.out.println("Please enter the total fee charged for the project: ");
totalFee = doubleCheck("total fee");
System.out.println("Please enter the total amount paid to date: ");
amountPaid = doubleCheck("total amount");
System.out.println("Please enter the project deadline (e.g. day, month, year: 10 November 2021) : ");
deadline = stringCheck("project deadline");
// New project object displayed to the user.
System.out.println("\nProject Number: " + projectNumber + "\nProjectName: " + projectName
+ "\nBuilding Type: " + buildingType + "\nPhysical Address: " + address + "\nERF Number: " + erfNumber + "\nTotal Fee: R"
+ totalFee + "\nAmount Paid: R" + amountPaid + "\nDeadline: " + deadline + "\nCompletion Date: " + Completion + "\nProject Status: " + Status);
String projectInfo = projectNumber + ", " + projectName + ", " + buildingType + ", " + address
+ ", " + erfNumber + ", " + totalFee + ", " + amountPaid + ", " + deadline + ", " + Completion
+ ", " + Status;
// Writing the string 'projectInfo' to the CurrentProjects.txt file.
// Try-catch block used to deal with any errors encountered.
try {
BufferedWriter out = new BufferedWriter(
new FileWriter("../CurrentProjects.txt", true));
out.write(projectInfo + "\r\n");
out.close();
System.out.println("Your project was successfully added.");
}
catch (IOException e) {
System.out.println("exception occurred" + e);
}
}
}