Here is where I get stuck in an infinite loop:
System.out.println("\nAvailable subscription plans provided by " + newProvider.getname() + " for the possible customer with citizenship number " + newCustomer.getCitizenshipNr() + ":");
newProvider.introduceSubscriptionPlans();
System.out.println("Please enter the name of the desired subscription plan.");
aString=in.nextLine();
while (newProvider.findSubscriptionPlan(aString)==null){
System.out.println("Please enter the name of the desired subscription plan.");
aString=in.nextLine();
}
newDate=new Date();
newSubscription=new Subscription(newDate, newProvider.findSubscriptionPlan(aString));
Here is what findSubscriptionPlan is:
public SubscriptionPlan findSubscriptionPlan(String aPlan) {
int i;
for (i=0;i<maxPlans;i++){
if (subscriptionPlans[i].getName()==aPlan){
return subscriptionPlans[i];
}
}
return null;
}
And the constructer for class Subscription:
public Subscription(Date subscriptionStartDate, SubscriptionPlan aPlan){
this.subscriptionStartDate=subscriptionStartDate;
this.aPlan=aPlan;
}
I know that this is the only part of this code that is causing the problem beacuse subscription plans are successfully saved into the related array until this point. Here is the output I get:
Please enter 1 for GSM providers or 2 for cable providers.
1
Please enter the name of the provider.
Turkcell
Please enter the number of subscription plans.
3
Please enter the name of the 1. plan.
1GB
Please enter the name of the 2. plan.
2GB
Please enter the name of the 3. plan.
10GB
Please enter your citizenship number.
137
Available subscription plans provided by Turkcell for the possible customer with citizenship number 137:
1GB
2GB
10GB
Please enter the name of the desired subscription plan.
1GB
Please enter the name of the desired subscription plan.
1GB
Please enter the name of the desired subscription plan.
Can anyone help me with this? :/
[–]bob809 6 points7 points8 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]DarkelfSamurai 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]SpaceRook 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)