From a51bf2858522f609c00674205caf45d9777916a6 Mon Sep 17 00:00:00 2001 From: Matthew <mxw@cs.washington.edu> Date: Mon, 5 Feb 2024 20:44:31 -0800 Subject: [PATCH] Generate (and require) alt text for images --- Employee.java | 8 +++++++- GenerateStaff.java | 3 ++- Product.java | 8 +++++++- Products.java | 8 +++++++- Staff.java | 16 ++++++++++++++-- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Employee.java b/Employee.java index 8ff1fad..9813a19 100644 --- a/Employee.java +++ b/Employee.java @@ -3,18 +3,24 @@ public class Employee { public String position; public String description; public String picture; + public String altText; - public Employee(String name, String position, String description, String picture) { + public Employee(String name, String position, String description, String picture, String altText) { this.name = name; this.position = position; this.description = description; this.picture = picture; + this.altText = altText; } public String getName() { return this.name; } + public String getAltText() { + return this.altText; + } + public String getDescription() { return this.description; } diff --git a/GenerateStaff.java b/GenerateStaff.java index 91d7ff3..e0a7308 100644 --- a/GenerateStaff.java +++ b/GenerateStaff.java @@ -30,6 +30,7 @@ public class GenerateStaff { String description = p.getDescription(); String picture = p.getPicture(); String position = p.getPosition(); + String altText = p.getAltText(); // Create new file File employeeFile = new File("staff/" + name + ".html"); @@ -42,7 +43,7 @@ public class GenerateStaff { outEmployeeFile.println(indent(3) + listStart); outEmployeeFile.println(indent(4) + itemStart + "<span class=\"about\">Position: " + position + "</span>" + itemEnd); outEmployeeFile.println(indent(4) + itemStart + "<span class=\"about\">About: " + description + "</span>" + itemEnd); - outEmployeeFile.println(indent(4) + "<img src=\"" + "../images/staff/" + picture + "\" target=\"_blank\"></img>"); + outEmployeeFile.println(indent(4) + "<img src=\"" + "../images/staff/" + picture + "\" target=\"_blank\" alt=\"" + altText + "\"></img>"); outEmployeeFile.println(indent(3) + listEnd); printFooter(outEmployeeFile); diff --git a/Product.java b/Product.java index b123824..0916d6f 100644 --- a/Product.java +++ b/Product.java @@ -2,12 +2,14 @@ public class Product { public String name; public String description; public String picture; + public String altText; public double price; - public Product(String name, String description, String picture, double price) { + public Product(String name, String description, String picture, String altText, double price) { this.name = name; this.description = description; this.picture = picture; + this.altText = altText; this.price = price; } @@ -15,6 +17,10 @@ public class Product { return this.name; } + public String getAltText() { + return this.altText; + } + public String getDescription() { return this.description; } diff --git a/Products.java b/Products.java index ecbcfc8..b639a81 100644 --- a/Products.java +++ b/Products.java @@ -1,6 +1,12 @@ /* check out these products! */ public class Products { /* a good class, but not as good as cse391 */ public Product joshsProduct() { - return new Product("Dirt", "The good stuff", "dirt.jpeg", 0.0); + return new Product( + "Dirt", + "The good stuff", + "dirt.jpeg", + "some normal brown dirt", + 0.0 + ); } } diff --git a/Staff.java b/Staff.java index 62f9494..edccd20 100644 --- a/Staff.java +++ b/Staff.java @@ -1,10 +1,22 @@ public class Staff { public Employee faangPup() { - return new Employee("Steve", "Company Pup", "Provides Moral Support", "pup.jpg"); + return new Employee( + "Steve", + "Company Pup", + "Provides Moral Support", + "pup.jpg", + "the goodest boi" + ); } public Employee cjobes() { - return new Employee("Colton", "Lead Naps Analyst", "What do you mean I'm not valuable to the company?", "colton.jpg"); + return new Employee( + "Colton", + "Lead Naps Analyst", + "What do you mean I'm not valuable to the company?", + "colton.jpg", + "Colton smiling with a forest in the background" + ); } } -- GitLab