我在理解声明时遇到了问题low in coupling and high in cohesion.我用Google搜索并阅读了很多相关信息,但仍然难以理解.
根据我的理解High cohesion,我们应该拥有专门用于执行特定功能的类.希望这是正确的吗?就像信用卡验证类一样,专门用于验证信用卡.
还是不明白低耦合意味着什么?
我正在尝试使用该alert方法,因此像popView这样的原生iOS会弹出.一切正常,警报会显示出来.但警报的标题总是如此index.html.
如何编辑alert方法的标题
我需要知道如何替换一个对象ArrayList<Animal>.
我有一个名为的数组列表ArrayList<Animal>.此列表仅列出了初始的5只动物.
Animal animal = new Animal();
animal.setName("Lion");
animal.setId(1);
ArrayList<Animal> a = new ArrayList<Animal>();
a.put(animal); // likewise i will be adding 5-6 animals here.
Run Code Online (Sandbox Code Playgroud)
稍后,我将从此数组列表中获取一个对象并进行修改.
Animal modifiedAnimal = new Animal();
animal.setName("Brown Lion");
animal.setId(1);
Run Code Online (Sandbox Code Playgroud)
现在我需要将此Animal对象添加到ArrayList<Animal> a 数组列表中.我需要它来替换Animal我们命名的前一个对象Lion.我怎样才能做到这一点 ?
注意:我不知道添加此对象的索引.
我需要用以下条件提醒用户;
这是代码; 如何在发生时捕获以下条件并提醒用户?
failure: function (response) {
var text = response.responseText;
console.log("FAILED");
},success: function (response) {
var text = response.responseText;
console.log("SUCCESS");
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下代码来检查互联网是否可以访问,但它不起作用
var networkState = navigator.network.connection.type
alert(states[networkState]);
if (networkState == Connection.NONE){
alert('No internet ');
};
Run Code Online (Sandbox Code Playgroud)
更新**
我在index.html中添加了以下内容,但是,当我禁用WIFI时,我看不到弹出警报.
<script>
function onDeviceReady() {
document.addEventListener("offline", function() {
alert("No internet connection");
}, false);
}
</script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试添加进度条.一切正常,我没有任何错误.但进度条从0%变为100%,甚至没有通过它之间的值(我的意思是它太快了,用户无法看到进度条块填写)
pr = new JProgressBar();
pr(0);
pr(true);
..
public void iterate(){
while (i<=20000){
pr.setValue(i);
i=i+1000;
try{
Thread.sleep(150);
}catch (Exception e){
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
单击i按钮时,我调用该iterate()方法,我希望它可以逐步更新进度条.相反,它会暂停一段时间,然后显示一个完整的进度条.
我怎么解决这个问题?
2.)我不喜欢进度条选项卡的默认蓝色.我需要改变颜色.我试过 pr.setForeground(Color.GRAY);
pr.setBackground(Color.RED);但它没用.
如何建模对图中static方法的调用class?有人可以给我一个指向class图表的链接吗?
例如,有一个名为Animal的类.我有另一个名为Vertibrates的类,它有一个静态的方法(这是该类中唯一的方法).我的Animal类将使用Vertibrate类的静态方法.因此,如何在类图中对其进行建模?
我在Python中遇到全局变量问题; 我已经在方法中定义了一个全局变量,我试图从另一个方法向它添加一些文本.
方法一:
def method1():
global v
v="hi "
print v
Run Code Online (Sandbox Code Playgroud)
方法2:
def method2():
print v # prints `hi`
v +="go home"
print v # doesn't append
Run Code Online (Sandbox Code Playgroud)
我怎么称呼:
method1()
method2()
Run Code Online (Sandbox Code Playgroud)
预期产量是hi go home,但我没有得到预期的产量.
我怎么解决这个问题?我需要附加一些文本method2()并显示它.
我从xCode项目中收到以下警告.我该如何摆脱它们?
注意:我使用MBProgessHud和FMDB
Warning: no rule to process file '$(PROJECT_DIR)/MBProgressHUD.h' of type sourcecode.c.h for architecture i386
Warning: no rule to process file '$(PROJECT_DIR)/SampleProj/../FMDatabase.h' of type sourcecode.c.h for architecture i386
Run Code Online (Sandbox Code Playgroud) 1家医院将有多名医生.我需要知道我可以存储的java collection类型(ArrayList,HashMap等)hospital ID和Doctor合适java collection类型的对象(ArrayList,HashMap等).
要求是我应该能够存储HospitalIDas key和Doctor对象value.
此外,我应该能够为各种Doctor对象使用相同的密钥(因为可能有许多医生为该医院工作).那么什么是我可以用于这种情况的java集合类型(ArrayList,HashMap等)?
注意:我不能使用HashMap- 因为它需要唯一的ID.
稍后,我应该能够筛选出为特定医院工作的所有医生(通过搜索它的ID),并显示其记录
我想用python拆分一个字符串.我已经成功地为一个变量完成了它,但发现它很难为2做.
字符串:
Paragraph 4-2 says. i am going home$ early- Yes.
Run Code Online (Sandbox Code Playgroud)
我需要输出
Paragraph 4-2 says
i am going home
early
Yes
Run Code Online (Sandbox Code Playgroud)
句子应该从.,$和-(但当它在2个数字(4-2)之间时,它不应该分开)
我怎样才能做到这一点?
text.split('.')
Run Code Online (Sandbox Code Playgroud)
UPDATE
新输出应该是:
Paragraph 4-2 says.
i am going home$
early-
Yes.
Run Code Online (Sandbox Code Playgroud) 我用2个Java关键字的有点混乱synchronized和volatile.
据我所知,由于java是一种multi-threaded语言,并且通过使用关键字synchronized将强制它在1个线程中执行.我对么 ?
而且volatile也做同样的事情?
我有一个字符串:
父亲吃了一根香蕉,睡在羽毛上
我的部分代码如下所示:
...
if word.endswith(('ther')):
print word
Run Code Online (Sandbox Code Playgroud)
这打印feather也Father
但我想修改它,if condition因此它不会将此搜索应用于句子的第一个单词.所以结果应该只打印feather.
我试过and但它没有用:
...
if word.endswith(('ther')) and word[0].endswith(('ther')):
print word
Run Code Online (Sandbox Code Playgroud)
这不起作用.救命
java ×4
python ×3
cordova ×2
extjs ×2
sencha-touch ×2
append ×1
arraylist ×1
collections ×1
fmdb ×1
iphone ×1
jprogressbar ×1
modeling ×1
objective-c ×1
ooad ×1
oop ×1
regex ×1
search ×1
string ×1
swing ×1
uml ×1