java - 在Java中使用默认说明符声明Hashmap时如何将Hashmap传递给另一个类(不同的包)
问题描述
Hacker Rank 提出了 SDET 编码挑战。
结构
类 DataEntryAutomationTest
public class DataEntryAutomationTest {
private static WebDriver driver = null;
private static String pagUrl = null;
static Map<String, String> data = null;
@SuppressWarnings("unchecked")
@BeforeClass
public static void setup() { //code for initializing driver.
data = new HashMap() {
{
put("11", "day");
put("July", "month");
put("1990", "year");
put("favorite_language", "Java,Python");
put("favorite_os", "Linux,Mac OSX");
put("favorite_idea", "IntelliJ IDEA");
}
};
pagUrl = "http://localhost:8080/home.html";
}
@Test
public void testFillDateOfBirth() {
DataEntryAutomation.fillDateOfBirth(driver, pagUrl);
}
@Test
public void testAnswerQuestions() {
DataEntryAutomation.answerQuestions(driver, pagUrl);
}
类 DataEntryAutomation
public class DataEntryAutomation {
public static void fillDateOfBirth(WebDriver driver, String pageUrl) {
//add code to fill the survey
}
public static void answerQuestions(WebDriver driver, String pageUrl) {
//add code to fill the survey
}
如何将 HashMap 传递给DataEntryAutomation 类,以便我可以使用 HashMap 来填写调查。我的理解是如果没有提到修饰符,那么默认的访问说明符是包。类可以访问同一个包中其他类的成员,但在包外它显示为私有。限制: 我只能编辑 DataEntryAutomation 类
解决方案
推荐阅读
- file - 为什么我的批处理脚本在提升时不能创建 .txt 文件?
- r - 创建一个包含 grepped 字符串的新列
- ajax - 为什么 Eclipse 内部浏览器停止在控制台上执行?
- php - 即使我们正在清理输入 mysql_real_escape_string 的 SQL 注入漏洞代码
- javascript - 如何使用 mongoose 从 MongoDB 获取数据
- python - 如何有效地将多个功能应用于数据框?
- dart - Dart:以字符串为参数的函数作为回调中的参数
- html - 仅在事件后加载 amp-list 数据
- authentication - Kentico 12 - 如何将单个页面设置为需要身份验证?
- jquery - 如果 jquery 中的空在 laravel 中不起作用,则返回