First Java Applet, the first java Applet

Source: Internet
Author: User

First Java Applet, the first java Applet

I want to learn about android development. I recently started to learn the java language. The programming languages I have used before are limited to the most basic C language, and the learning of C ++ is limited to syntax, class and other concepts have not been touched yet. in order to learn Java, I initially bought the famous Thinking in Java, but after several pages, I found that it is not suitable for beginners to learn, I switched to the Java video of Miss Bi Xiangdong. I spent two days to read and encapsulate this part of content. During this period, I did not write code with the teacher, I feel like I will soon forget it, so I stopped and wanted to write some code to my own trainer. So I wrote a simple user name and password verification applet.

 

This is the first code except helloworld. It is still vague about when to use classes, methods, private, and static.

I hope that some of my friends and friends will give me some suggestions to facilitate future progress. Thank you ~~~

1/** 2 requirement analysis: 3 simple verification logon System 4 */

 

1/** 2 requirement analysis: 3 simple verification logon System 4 */5 import java. util. *; 6 import java. io. *; 7. // The display interface at the beginning of the program, including the software author, introduction, and other functions. 9 class StartScene 10 {11 public static void PrintStartScene () 12 {13 System. out. println ("\ n \ t welcome to use the Student Status Management System (simple edition)"); 14 System. out. println ("\ t Author: YangSH1996"); 15 System. out. println ("\ t time: 2015/12/1"); 16 System. out. println (""); 17 // create a new Login object 18 Login lg = new Login (); 19} 20 21} 22 23 // used for Login, go to System 24 class Login 25 {26 // set the correct username and password 27 private String correctName =" Dministrator "; 28 private String correctPassword =" admin123 "; 29 30 // constructor 31 Login () 32 {33 getNameAndPassword (); 34} 35 36 // enter 37 void getNameAndPassword () 38 {39 login SC = new Login (System. in); 40 System. out. print ("\ t enter your Username:"); 41 String getName = SC. nextLine (); 42 System. out. print ("\ t enter your password:"); 43 String getPassword = SC. nextLine (); 44 judgeNameAndPassword (getName, getPass Word); 45} 46 47 // determine the correctness of the user name and password 48 void judgeNameAndPassword (String getName, String getPassword) 49 {50 if (! GetName. equals (correctName) 51 {52 System. out. println ("\ t username does not exist! "); 53 login sc1 = new Login (System. in); 54 System. out. print (" \ t do you want to exit? Y/N \ t "); 55 String choice = sc1.nextLine (); 56 if (choice. charAt (0) = 'y' | choice. charAt (0) = 'y') 57 {58 System. out. println ("\ n \ t thank you for your use. \ N "); 59 System. exit (0); 60} 61 62 getNameAndPassword (); 63} 64 else 65 {66 if (! GetPassword. equals (correctPassword) 67 {68 System. out. println ("\ t Password error! "); 69 getNameAndPassword (); 70} 71 else 72 {73 System. out. print (" \ t correct! Welcome to log on. The Menu \ n "will be displayed soon. 74 menu Menu = new Menu (); // execution Menu 75} 76} 77} 78 79 80} 81 82 // Menu 83 class Menu 84 {85 Menu () 86 {87 88 try {89 System. out. println ("\ t3 seconds later program exited"); 90 Thread. sleep (1000); 91 System. out. println ("\ 2 seconds later the program exits"); 92 Thread. sleep (1000); 93 System. out. println ("\ t1 seconds later program exited"); 94 Thread. sleep (1000); 95} catch (InterruptedException e) {96 e. printStackTrace (); 97} 98 99} 100 101 102 103 // class where the main function is located 104 public class Practice20151218106 {105 // entry for jvm recognition main function 107 public static void main (String [] args) 109 {110 StartScene ss = new StartScene (); 111 StartScene. printStartScene (); 112 113} 114}

 

 

I hope that the vast majority of friends and friends can give me some suggestions, any little bit, to facilitate my future progress. Thank you ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.