java - Math from extended class being ignored? -
have been working code couple days , cannot figure out why skills not using math assigned in attributes.java
if allocate 5 points intelligence, science should compute 60. instead science computing 30. think program using original 5 points set @ calculation, instead of upgraded 10?
attributes.java
public class attributes { static int strength = 5; static int perception = 5; static int endurance = 5; static int charisma = 5; static int intelligence = 5; static int agility = 5; static int luck = 5; static int hitpoints = ((endurance * 4) + (strength)); static int armorclass = (endurance + 1); static int actionpoints = (agility + 1); static int carryweight = ((strength * 30) + 5); static int meleedamage = (strength / 2); static int damageresis = (endurance + 1); static int poisonresis = (endurance * 5); static int radresis = (endurance * 2); static int sequence = (perception + agility); static int healingrate = (endurance / 2); static int criticalchance = (((luck * 2) + (agility / 3)) + 1); static int smallguns = ((perception + agility + luck) * 2); static int bigguns = (((strength / 2) + (perception / 2) + agility + luck) * 2); static int energyweapons = (((intelligence / 2)+ (perception / 2) + agility + luck) * 2); static int unarmed = (((strength / 2) + (perception / 2) + (agility / 2) + (endurance / 2) + luck) * 2); static int meleeweapons = (((strength / 2) + (perception / 2) + (agility / 2) + (endurance / 2) + luck) * 2); static int throwing = (((strength / 2) + (perception / 2) + agility + luck) * 2); static int firstaid = (((intelligence * 2) + perception) * 2); static int doctor = ((intelligence * 3) * 2); static int sneak = (((perception / 2) + (luck / 2) + (agility * 2)) * 2); static int lockpick = (((perception / 2) + (luck / 2) + agility + intelligence) * 2); static int steal = (((perception / 2) + (luck / 2) + (agility * 2)) * 2); static int traps = (((perception / 2) + (luck / 2) + agility + intelligence) * 2); static int science = ((intelligence * 3) * 2); static int repair = (((agility / 2) + (perception / 2) + (intelligence * 2)) * 2); static int speech = ((intelligence + (charisma * 2)) * 2); static int barter = ((intelligence + (charisma * 2)) * 2); static int gambling = ((luck * 3) * 2); static int outdoors = (((strength / 2) + (agility / 2) + (intelligence / 2) + (luck / 2) + endurance) * 2); }
game.java
import java.util.scanner; public class game extends attributes{ public static void main(string[] args){ string enter = "press enter continue."; string name = null; int age = 0; string gender = null; system.out.println(); system.out.println(); system.out.println(); system.out.println(); system.out.println(); system.out.println(" *** welcome fallout! ***"); system.out.println(); system.out.println("press enter begin character creation."); scanner pressenter = new scanner(system.in); pressenter.nextline(); scanner namescan = new scanner(system.in); system.out.println("what name?"); name = namescan.nextline(); system.out.println("greetings " + name + "!"); system.out.println(); scanner agescan = new scanner(system.in); system.out.println("how old you?"); while (agescan.hasnextint()) { age = agescan.nextint(); if ((age <= 82) && (age >=18)) break; else system.out.println("please choose number between 18 & 82"); } system.out.println(age + ". got it."); system.out.println(); scanner genderscan = new scanner(system.in); system.out.println("are male or female?"); while (genderscan.hasnextline()) { gender = genderscan.nextline(); if (gender.equalsignorecase("male") || gender.equalsignorecase("female")) break; else system.out.println("please choose male or female"); } system.out.println(gender + ". noted."); system.out.println(); system.out.println(enter); pressenter.nextline(); system.out.println("your attributes follows:"); system.out.println("strength: " + strength); system.out.println("perception: " + perception); system.out.println("endurance: " + endurance); system.out.println("charisma: " + charisma); system.out.println("intelligence: " + intelligence); system.out.println("agility: " + agility); system.out.println("luck: " + luck); system.out.println(enter); pressenter.nextline(); system.out.println(); system.out.println("you have 5 attribute points allocate."); system.out.println("what increase?"); system.out.println("strength, perception, endurance, charisma, intelligence, agility or luck?"); scanner scanfirstpoint = new scanner(system.in); string inputfirstpoint = null; while (scanfirstpoint.hasnextline()) { inputfirstpoint = scanfirstpoint.nextline(); if (inputfirstpoint.equalsignorecase("strength") || inputfirstpoint.equalsignorecase("perception") || inputfirstpoint.equalsignorecase("endurance") || inputfirstpoint.equalsignorecase("charisma") || inputfirstpoint.equalsignorecase("intelligence") || inputfirstpoint.equalsignorecase("agility") || inputfirstpoint.equalsignorecase("luck")) break; else system.out.println("please choose strength, perception, endurance, charisma, " + "intelligence, agility or luck"); } if (inputfirstpoint.equalsignorecase("strength")) { system.out.println("strength increased 1!"); strength ++; system.out.println("strength: " + strength); } else if (inputfirstpoint.equalsignorecase("perception")) { system.out.println("perception increased 1!"); perception ++; system.out.println("perception: " + perception); } else if (inputfirstpoint.equalsignorecase("endurance")) { system.out.println("endurance increased 1!"); endurance ++; system.out.println("endurance: " + endurance); } else if (inputfirstpoint.equalsignorecase("charisma")) { system.out.println("charisma increased 1!"); charisma ++; system.out.println("charisma: " + charisma); } else if (inputfirstpoint.equalsignorecase("intelligence")) { system.out.println("intelligence increased 1!"); intelligence ++; system.out.println("intelligence: " + intelligence); } else if (inputfirstpoint.equalsignorecase("agility")) { system.out.println("agility increased 1!"); agility ++; system.out.println("agility: " + agility); } else if (inputfirstpoint.equalsignorecase("luck")) { system.out.println("luck increased 1!"); luck ++; system.out.println("luck: " + luck); } system.out.println(); system.out.println("you have 4 attribute points allocate."); system.out.println("what increase?"); system.out.println("strength, perception, endurance, charisma, intelligence, agility or luck?"); scanner scansecondpoint = new scanner(system.in); string inputsecondpoint = null; while (scansecondpoint.hasnextline()) { inputsecondpoint = scansecondpoint.nextline(); if (inputsecondpoint.equalsignorecase("strength") || inputsecondpoint.equalsignorecase("perception") || inputsecondpoint.equalsignorecase("endurance") || inputsecondpoint.equalsignorecase("charisma") || inputsecondpoint.equalsignorecase("intelligence") || inputsecondpoint.equalsignorecase("agility") || inputsecondpoint.equalsignorecase("luck")) break; else system.out.println("please choose strength, perception, endurance, charisma, " + "intelligence, agility or luck"); } if (inputsecondpoint.equalsignorecase("strength")) { system.out.println("strength increased 1!"); strength ++; system.out.println("strength: " + strength); } else if (inputsecondpoint.equalsignorecase("perception")) { system.out.println("perception increased 1!"); perception ++; system.out.println("perception: " + perception); } else if (inputsecondpoint.equalsignorecase("endurance")) { system.out.println("endurance increased 1!"); endurance ++; system.out.println("endurance: " + endurance); } else if (inputsecondpoint.equalsignorecase("charisma")) { system.out.println("charisma increased 1!"); charisma ++; system.out.println("charisma: " + charisma); } else if (inputsecondpoint.equalsignorecase("intelligence")) { system.out.println("intelligence increased 1!"); intelligence ++; system.out.println("intelligence: " + intelligence); } else if (inputsecondpoint.equalsignorecase("agility")) { system.out.println("agility increased 1!"); agility ++; system.out.println("agility: " + agility); } else if (inputsecondpoint.equalsignorecase("luck")) { system.out.println("luck increased 1!"); luck ++; system.out.println("luck: " + luck); } system.out.println(); system.out.println("you have 3 attribute points allocate."); system.out.println("what increase?"); system.out.println("strength, perception, endurance, charisma, intelligence, agility or luck?"); scanner scanthirdpoint = new scanner(system.in); string inputthirdpoint = null; while (scanthirdpoint.hasnextline()) { inputthirdpoint = scanthirdpoint.nextline(); if (inputthirdpoint.equalsignorecase("strength") || inputthirdpoint.equalsignorecase("perception") || inputthirdpoint.equalsignorecase("endurance") || inputthirdpoint.equalsignorecase("charisma") || inputthirdpoint.equalsignorecase("intelligence") || inputthirdpoint.equalsignorecase("agility") || inputthirdpoint.equalsignorecase("luck")) break; else system.out.println("please choose strength, perception, endurance, charisma, " + "intelligence, agility or luck"); } if (inputthirdpoint.equalsignorecase("strength")) { system.out.println("strength increased 1!"); strength ++; system.out.println("strength: " + strength); } else if (inputthirdpoint.equalsignorecase("perception")) { system.out.println("perception increased 1!"); perception ++; system.out.println("perception: " + perception); } else if (inputthirdpoint.equalsignorecase("endurance")) { system.out.println("endurance increased 1!"); endurance ++; system.out.println("endurance: " + endurance); } else if (inputthirdpoint.equalsignorecase("charisma")) { system.out.println("charisma increased 1!"); charisma ++; system.out.println("charisma: " + charisma); } else if (inputthirdpoint.equalsignorecase("intelligence")) { system.out.println("intelligence increased 1!"); intelligence ++; system.out.println("intelligence: " + intelligence); } else if (inputthirdpoint.equalsignorecase("agility")) { system.out.println("agility increased 1!"); agility ++; system.out.println("agility: " + agility); } else if (inputthirdpoint.equalsignorecase("luck")) { system.out.println("luck increased 1!"); luck ++; system.out.println("luck: " + luck); } system.out.println(); system.out.println("you have 2 attribute points allocate."); system.out.println("what increase?"); system.out.println("strength, perception, endurance, charisma, intelligence, agility or luck?"); scanner scanfourthpoint = new scanner(system.in); string inputfourthpoint = null; while (scanfourthpoint.hasnextline()) { inputfourthpoint = scanfourthpoint.nextline(); if (inputfourthpoint.equalsignorecase("strength") || inputfourthpoint.equalsignorecase("perception") || inputfourthpoint.equalsignorecase("endurance") || inputfourthpoint.equalsignorecase("charisma") || inputfourthpoint.equalsignorecase("intelligence") || inputfourthpoint.equalsignorecase("agility") || inputfourthpoint.equalsignorecase("luck")) break; else system.out.println("please choose strength, perception, endurance, charisma, " + "intelligence, agility or luck"); } if (inputfourthpoint.equalsignorecase("strength")) { system.out.println("strength increased 1!"); strength ++; system.out.println("strength: " + strength); } else if (inputfourthpoint.equalsignorecase("perception")) { system.out.println("perception increased 1!"); perception ++; system.out.println("perception: " + perception); } else if (inputfourthpoint.equalsignorecase("endurance")) { system.out.println("endurance increased 1!"); endurance ++; system.out.println("endurance: " + endurance); } else if (inputfourthpoint.equalsignorecase("charisma")) { system.out.println("charisma increased 1!"); charisma ++; system.out.println("charisma: " + charisma); } else if (inputfourthpoint.equalsignorecase("intelligence")) { system.out.println("intelligence increased 1!"); intelligence ++; system.out.println("intelligence: " + intelligence); } else if (inputfourthpoint.equalsignorecase("agility")) { system.out.println("agility increased 1!"); agility ++; system.out.println("agility: " + agility); } else if (inputfourthpoint.equalsignorecase("luck")) { system.out.println("luck increased 1!"); luck ++; system.out.println("luck: " + luck); } system.out.println(); system.out.println("you have 1 attribute points allocate."); system.out.println("what increase?"); system.out.println("strength, perception, endurance, charisma, intelligence, agility or luck?"); scanner scanfifthpoint = new scanner(system.in); string inputfifthpoint = null; while (scanfifthpoint.hasnextline()) { inputfifthpoint = scanfifthpoint.nextline(); if (inputfifthpoint.equalsignorecase("strength") || inputfifthpoint.equalsignorecase("perception") || inputfifthpoint.equalsignorecase("endurance") || inputfifthpoint.equalsignorecase("charisma") || inputfifthpoint.equalsignorecase("intelligence") || inputfifthpoint.equalsignorecase("agility") || inputfifthpoint.equalsignorecase("luck")) break; else system.out.println("please choose strength, perception, endurance, charisma, " + "intelligence, agility or luck"); } if (inputfifthpoint.equalsignorecase("strength")) { system.out.println("strength increased 1!"); strength ++; system.out.println("strength: " + strength); } else if (inputfifthpoint.equalsignorecase("perception")) { system.out.println("perception increased 1!"); perception ++; system.out.println("perception: " + perception); } else if (inputfifthpoint.equalsignorecase("endurance")) { system.out.println("endurance increased 1!"); endurance ++; system.out.println("endurance: " + endurance); } else if (inputfifthpoint.equalsignorecase("charisma")) { system.out.println("charisma increased 1!"); charisma ++; system.out.println("charisma: " + charisma); } else if (inputfifthpoint.equalsignorecase("intelligence")) { system.out.println("intelligence increased 1!"); intelligence ++; system.out.println("intelligence: " + intelligence); } else if (inputfifthpoint.equalsignorecase("agility")) { system.out.println("agility increased 1!"); agility ++; system.out.println("agility: " + agility); } else if (inputfifthpoint.equalsignorecase("luck")) { system.out.println("luck increased 1!"); luck ++; system.out.println("luck: " + luck); } system.out.println(); system.out.println("your new attributes are:"); system.out.println("strength: " + strength); system.out.println("perception: " + perception); system.out.println("endurance: " + endurance); system.out.println("charisma: " + charisma); system.out.println("intelligence: " + intelligence); system.out.println("agility: " + agility); system.out.println("luck: " + luck); system.out.println(enter); pressenter.nextline(); system.out.println(); system.out.println("your skills follows:"); system.out.println("small guns: " + smallguns); system.out.println("big guns: " + bigguns); system.out.println("energy weapons: " + energyweapons); system.out.println("unarmed: " + unarmed); system.out.println("melee weapons: " + meleeweapons); system.out.println("throwing: " + throwing); system.out.println("first aid: " + firstaid); system.out.println("doctor: " + doctor); system.out.println("sneak: " + sneak); system.out.println("lockpick: " + lockpick); system.out.println("steal: " + steal); system.out.println("traps: " + traps); system.out.println("science: " + science); system.out.println("repair: " + repair); system.out.println("speech: " + speech); system.out.println("barter: " + barter); system.out.println("gambling: " + gambling); system.out.println("outdoors: " + outdoors); system.out.println(enter); pressenter.nextline(); system.out.println(); } }
i need 50 reputation comment, i'll answer question. calculated values aren't being updated when add points base values. need update values after assigning skill points.
edit: make clearer - strength, perception, endurance, intelligence, agility, charisma, , luck initialized 5. values can add points increase in value. rest of values(hitpoints, science, etc) calculated those. however, when choose spend skill points, aren't recalculating other values depend on base values.
Comments
Post a Comment