Repository navigation
Expand file tree
/
Copy pathcoursesStyle.java
More file actions
70 lines (57 loc) · 3.21 KB
/
Copy pathcoursesStyle.java
File metadata and controls
70 lines (57 loc) · 3.21 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
import java.io.FileWriter;
import java.io.IOException;
public class CourseHTMLGenerator {
public static void main(String[] args) {
generateHTML();
}
public static void generateHTML() {
try (FileWriter writer = new FileWriter("courses.html")) {
writer.write("<!DOCTYPE html>\n");
writer.write("<html lang=\"en\">\n");
writer.write("<head>\n");
writer.write(" <meta charset=\"UTF-8\">\n");
writer.write(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n");
writer.write(" <link rel=\"stylesheet\" href=\"styles.css\">\n");
writer.write(" <title>Courses</title>\n");
writer.write("</head>\n");
writer.write("<body>\n");
// Side Panel with Reminders, Assignments, and Announcements
writeSidePanel(writer);
// Main Content - Courses and Sections
writeCourse(writer, "Java Programming", "Introduction", "This section covers the basics of Java programming.");
writeCourse(writer, "Java Programming", "Advanced Topics", "Explore advanced Java concepts such as multithreading and design patterns.");
writeCourse(writer, "Web Development with Spring Boot", "Building RESTful APIs", "Learn to create RESTful APIs using Spring Boot.");
writeCourse(writer, "Web Development with Spring Boot", "Frontend Development", "Explore frontend development with Thymeleaf and HTML.");
writer.write("</body>\n");
writer.write("</html>");
System.out.println("HTML file generated successfully.");
} catch (IOException e) {
e.printStackTrace();
}
}
private static void writeSidePanel(FileWriter writer) throws IOException {
writer.write(" <div class=\"side-panel\">\n");
writer.write(" <h2>Reminders</h2>\n");
writer.write(" <ul>\n");
writer.write(" <li>Assignment due on 2022-12-15</li>\n");
writer.write(" <li>Quiz next week</li>\n");
writer.write(" </ul>\n");
writer.write(" <h2>Pending Assignments</h2>\n");
writer.write(" <ul>\n");
writer.write(" <li>Project proposal</li>\n");
writer.write(" <li>Homework set 3</li>\n");
writer.write(" </ul>\n");
writer.write(" <h2>Announcements</h2>\n");
writer.write(" <p>Welcome to the course! Please check the syllabus for important information.</p>\n");
writer.write(" </div>\n");
}
private static void writeCourse(FileWriter writer, String courseTitle, String sectionTitle, String sectionContent) throws IOException {
writer.write(" <div class=\"course\">\n");
writer.write(" <h2 class=\"course-title\">" + courseTitle + "</h2>\n");
writer.write(" <div class=\"section\">\n");
writer.write(" <h3 class=\"section-title\">" + sectionTitle + "</h3>\n");
writer.write(" <p class=\"section-content\">" + sectionContent + "</p>\n");
writer.write(" </div>\n");
writer.write(" </div>\n");
}
}