-
i need help with my code plz
}
public void setStunned(boolean stun){
stunning = stun;
}
public int getMaxMana() {
return maximumMana;
}
public int getCurrentHealth() {
return currentHealth1;
}
public int getCurrentMana() {
return currentMana1;
}
public int getMagicResist() {
return magResist;
}
public int
public void setMaxHealth(int maxH) {
maximumHealth = maxH;
}
public void setAttackPower(int attDamage) {
k.put("AttackPower", attDamage);
}
publentHealth1 = curHealth;
}
public void setCurrentMana(int curMana) {
currentMana1 = curMana;
}
public Skill[] getSkills() {
return championSkills;
}
public boolean isStunned(){
return stunning;
}
public Skill getBasicSkill() {
for(int initial = 1; initial <= championSkills.length; initial++) { //for loop on the whole array champion skill to check if isBasic is true or not if it is not return null
if(championSkills[initial].isBasic()== true){
return championSkills[initial];
}
}
return null;
}
pu
}
}
public boolean isSilenced(){
return silencing;
}
}
-
Re: i need help with my code plz
What is your question or problem?
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
-
Re: i need help with my code plz
-
Re: i need help with my code plz
Copy the full text of the error messages and paste it here.
-
Re: i need help with my code plz
all the errors in test class
--- Update ---
java.lang.NullPointerException
at eg.edu.guc.lol.game.champions.Skill.setBasic(Skill .java:30)
at PublicChampionTests.setup(PublicChampionTests.java :27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.e valuate(RunBefores.java:27)
at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
--- Update ---
what is wrong with method isBasic in skill class
?
-
Re: i need help with my code plz
Quote:
java.lang.NullPointerException
at eg.edu.guc.lol.game.champions.Skill.setBasic(Skill .java:30)
There is a variable with a null value on line 30. Look at line 30 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
If you can not tell which variable it is, add a println just before line 30 and print out the values of all the variables on that line.
-
Re: i need help with my code plz
There is no variable with a null value on line 30. check it plz
-
Re: i need help with my code plz
What statement is on line 30?
If there is a NPE thrown on that line, that means there is a variable with a null value on that line. You need to find the variable and then fix the code so it does not have a null value.
-
Re: i need help with my code plz
Code java:
public void setBasic(boolean ba){
h.put("Basic", ba);
}
you mean the variable basic
-
Re: i need help with my code plz
What value does the variable h have? Add a println to print its value.
There is no variable named basic in that code.
-
Re: i need help with my code plz
h is a hashmap with key(strings) and value(boolean)
--- Update ---
?
-
Re: i need help with my code plz
-
Re: i need help with my code plz
i don't know
--- Update ---
please can you tell me what i have to do to fix it, sorry?
-
Re: i need help with my code plz
Print out its value to see.
-
Re: i need help with my code plz
in which class?
--- Update ---
?
-
Re: i need help with my code plz
Add the println just before line 30 where the NPE happens.
Did you miss reading post#6?
-
Re: i need help with my code plz
can u write it down to understand
-
Re: i need help with my code plz
Write what down?
Do you know how to use the println() method to print out the values of variables?
Use it to print out the value of h
-
Re: i need help with my code plz
[
instance.setSkills(skills);
Champion target = new Champion("Annie", attributes, 500, 400);
instance.useSkill(target, 0, true);
assertEquals("Target should lose health as expected", 383, target.getCurrentHealth());
}
}
[/code]
-
Re: i need help with my code plz
What was the value of h when you printed it out?
-
Re: i need help with my code plz
the value null
null
null
......and so on 19 null value
--- Update ---
?
-
Re: i need help with my code plz
Why is the value of h null? The code needs to assign a value to h. Where is the missing code that should be assigning a value to h? If there is code that assigns a value to h, why isn't that code being executed?
-
Re: i need help with my code plz
-
Re: i need help with my code plz
why what? When you ask a question include enough details so it can be understood.
-
Re: i need help with my code plz
how can i assign values to h?