What´s wron with this code?
Code java:
import java.util.ArrayList;
import java.util.Scanner;
public class Prylregister {
Scanner tangentbord = new Scanner(System.in);
public static void main(String[] args) {
ArrayList<Pryl> allaPrylar = new ArrayList<Pryl>();
ArrayList<Person> allaPersoner = new ArrayList<Person>();
Scanner tangentbord = new Scanner(System.in);
System.out.println("Hej och välkommen till Prylprogrammet! ");
for(;;){
System.out.print("1 Skapa person, 2 Skapa pryl, 3 Visa alla, 4 Visa rikaste, 5 Visa viss person,6 Börskrash, 7 Avsluta: ");
int kommando = Integer.parseInt(tangentbord.nextLine());
switch (kommando){
case 1: System.out.print("Skapa person ");
System.out.println("Ange namn: ");
String namn = tangentbord.nextLine();
for (int x = 0; x<allaPersoner.size(); x++){
if(allaPersoner.size()>0){
for(Person p : allaPersoner) {
if (p.getNamn().equalsIgnoreCase(namn)) {
System.out.println("Den personen finns redan ");
}
else {
allaPersoner.add(new Person(namn));
}
}
}
}
Re: What´s wron with this code?
If there are errors you need to copy the full text and paste it here.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: What´s wron with this code?
as far as i can understand.. u missed a lots of '}'....
also you declared Scanner object "tangentbord" twice.....
assuming you have written Pryl and Person classes.....i couldn't find any more errors.
Re: What´s wron with this code?
Thank you for your answer!
In case 1 i want to register a person in arrayList if the person does not already exist but the code do nothing so far ?!
Re: What´s wron with this code?
dude... first post the code as Norm said...
also post the errors.......