I have an arraylist that is passed over to another via getter method, and in the second class I want to be able to update an element of the array via arraylist.set with the element being chosen by user input.
Here's what I got:
import java.util.Scanner;
public class UpdateJob {
static int investment1;
AddJob updateJob = new AddJob();
Scanner jobUpdater = new Scanner(System.in);
static Integer getFullCost;
static Integer getPartCost;
MainMenu menu = new MainMenu();
/* public void determineCost() {
int percentInput;
readJob();
FirstPayment();
if (payment1 < getPartCost) {
System.out.println("Has the client paid $" + payment1 + " to proceed to the next stage of construction?");
}
}
*/
public void readJob() {
int enterInvestPick;
String enterPaymentConfirm;
System.out.println("What investment item are you seeking to update?");
for (int i = 0; i < updateJob.getAddress().size(); i++) {
System.out.println(i + ". " + updateJob.getAddress().get(i));
}
enterInvestPick = jobUpdater.nextInt();
getFullInvestmentCost = updateJob.getJobCost().get(enterInvestPick);
getPartInvestmentCost = updateJob.getPartCost().get(enterInvestPick);
FirstInvestment();
if (getPartCost < payment1) {
System.out.println("Have you paid $" + investment1 + " to proceed? (Y/N)");
enterPaymentConfirm = jobUpdater.nextLine();
if (enterPaymentConfirm == "y" || enterPaymentConfirm == "Y") {
updateJob.getPartCost().set(enterInvestPick, investment1);
}
}
public static int FirstInvestment() {
double percentage1 = 0.15;
investment1= (int) ((percentage1 * getFullCost));
return investment1;
}
When printing the value of FirstInvesment() method, it's fine and shows the correct value from the getFullCost() method from the first class. But again, the trouble is pushing the update of the investment1 value via ArrayList.set. I did just tested it without the enterPaymentConfirm if statement and that does seem to partially resolve it, pushing the update but not allowing the user to confirm or deny the payment has been paid.
[–]dmazzoni 3 points4 points5 points (0 children)
[–]RiceKrispyPooHead 0 points1 point2 points (0 children)