یک سوال فوری !#جاوا
به نام خدا
سلام
من دارم کد یه دفترچه یادداشت رو مینویسم به زبان جاوا که پروژه ی درسیمه
ولی چند تا مشکل بزرگ دارم و هر چی سرچ میکنم به نتیجه نمیرسم!
1- برای نوشتن منو، از حلقه ی وایل و سوییچ کیس استفاده کردم، ولی منو تکرار نمیشه
یعنی وقتی کاربر گزینه ی 1 رو انتخاب میکنه، بعد از تموم شدن بلاک کیس 1، دیگه برنامه متوقف میشه
2- از پرینت رایتر برای ذخیره کردن نوت ها تو فایل تکست استفاده کردم، ولی هر بار که برنامه دوباره راان میشه، نوشته های قبلی نوت پاک میشن!
3- کد گرافیک برنامه رو تو نت بینز دارم، ولی نمیدونم چطور باید ازش استفاده کنم!
خیلی ممنون میشم اگر کمکم کنید مهندسین گرامی
3 پاسخ
شما می توانید به جای استفاده از حلقه های اضافی کار خودتون رو با یک while به صورت زیر انجام دهید و منوی شما هر بار تکرا ر خواهد شد:
import java.util.Scanner;
public class Page {
            public static void main(String[]args){
        System.out.print("Welcome to your Private Notebook!\nPlease Enter your Choice:\n");
                boolean isRunning=true;
                while (isRunning){
                    System.out.println("1=Let's make a new Note!\n2=I want to Remove some of my Notes!!\n3=I want to Find one of my Notes!\n4=Show me all of the Notes!\n5=CLOSE it!\n\t\t\t\t~~_~~_~~_~~");
                    Scanner choice = new Scanner(System.in);
                    int j;
                    int c=choice.nextInt();
                    switch (c){
                        case 1:
                            System.out.println("You entered 1");
                            break;
                        case 2:
                            System.out.println("You etered 2");
                            break;
                        case 3:System.out.println("you enterd 3");
                            break;
                        case 4:
                            System.out.println("You enterd 4");
                            break;
                        case 5:
                            System.out.println("You want to exit");
                            isRunning=false;
                            break;
                    }
                }
}
}
                                    سلام به شما Itpro ای عزیز.
لطفا کد قسمتهایی رو که گفتید رو توی سایت بذارید تا دوستان بتونن کمکتون بکنن.
خیلی ممنون از راهنماییتون
public class  Page {
	public static void main(String[]args){
		
		System.out.print("Welcome to your Private Notebook!\nPlease Enter your Choice:\r\r");
for(;;){
	
	{
		for(;;){
			NoteBook note = new NoteBook();
			System.out.println("1=Let's make a new Note!\r\r2=I want to Remove some of my Notes!!\r\r3=I want to Find one of my Notes!\r\r4=Show me all of the Notes!\r\r5=CLOSE it!\r\r\t\t\t\t~~_~~_~~_~~");
			Scanner choice = new Scanner(System.in);
			int j;	
			while(choice.hasNextInt()){
				
				int c1 = choice.nextInt();
				switch(c1){
				case 1:
					String[] subPage = new String[3];
					String sub = subPage[0];
					String matn = subPage[1];
					String date = subPage[2];
					Scanner text = new Scanner(System.in);
					note.make();
					System.out.println("\rInsert your Note's Subject:\r\r");
					sub = text.nextLine();
					System.out.println("\rInsert your Context:\r\r");
					matn = text.nextLine();
					System.out.println("\rInsert Date:\r\r");
					date = text.nextLine();
					try{
						PrintWriter zakhire = new PrintWriter("untitled 1.txt");
						zakhire.println("Subject:"+sub);
						zakhire.println("\r\rContext:"+matn);
						zakhire.println("\r\rDate:"+date);
						zakhire.print("\r\t\t\t\t\t\t\t+__+__+__+__+\r");
						zakhire.close();
					} 
					catch(FileNotFoundException ex){
						System.out.println("Please choose an available File on your Device, to save your Note!");
					}	
j = 1;
					break;
				case 2:
					System.out.println("\nInsert the Note's number wich you want to Delete:\r");
					Scanner num = new Scanner(System.in);
					int n1 = num.nextInt();
					note.ommit(n1);
					j = 1;
					break;
				case 3:
					System.out.println("\nInsert the Note's number wich you want to Find:\r");
					Scanner num1 = new Scanner(System.in);
					int n2 = num1.nextInt();
					note.search(n2);
					j = 1;
					break;
					
				case 4:
					System.out.println("\nThe number of your Notes: ");
					note.tedad();
					note.view();
					try{
						FileReader list = new FileReader("untitled 1.txt");
					}
					catch(FileNotFoundException ex){
						System.out.println("Your File path is incorrect!");
					}
					j = 1;
					break;
				case 5:
					j = -1;
					break;
				}
			}
			continue;
		}
				
			}
		
	}
}
}
این کد کلاس اجرایی هست. بسیار نیازمند یاری سبز آی تی پروئی های گرامی هستیم