Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the supermarket member Management system by Java

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Java how to achieve the supermarket member management system related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Java how to achieve the supermarket member management system article will have a harvest, let's take a look.

Requirements: implement the system with the help of collection framework and practical classes

1. Accumulate points

2. Points exchange

3. Query the remaining credits

4. Change the password

5. Open a card

6. Quit

Execution result:

The part of card opening and integral accumulation:

Exchange points, query the remaining points:

Change the password and use the new password to query:

Exit section:

The idea of realization is:

1. Create a member user class:

User name, password, membership card number (randomly generated), registration date, points

2. Create a supermarket business class:

Menu display

Business selection points access method, points exchange method, points query method, password modification method, card opening method

Determine whether there is a query element method in the collection (because the code in this method appears in other methods, it is extracted as a separate method)

3. Test class

Source code:

Member user category

Package cn.zyq.Aug0203;/** * member user class * @ author admin * * / public class Member {/ / name private String name; / / password private String pwd; / / member card number private String id; / / Registration date private String registData; / / Credit private int score Public Member () {} public Member (String name, String pwd, String id, String registData, int score) {super (); this.name = name; this.pwd = pwd; this.id = id; this.registData = registData; this.score = score;} public String getName () {return name } public void setName (String name) {this.name = name;} public String getPwd () {return pwd;} public void setPwd (String pwd) {this.pwd = pwd;} public String getId () {return id;} public void setId (String id) {this.id = id;} public String getRegistData () {return registData } public void setRegistData (String registData) {this.registData = registData;} public int getScore () {return score;} public void setScore (int score) {this.score = score;}}

Supermarket business category

Package cn.zyq.Aug0203;/** * supermarket business class * / import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.List;import java.util.Random;import java.util.Scanner;public class Business {Scanner sc = new Scanner (System.in); List list = new ArrayList () / * * users can choose menu * / public void init () {System.out.println ("\ n-Welcome to the member management system -\ n"); System.out.println ("1. The cumulative total of points is 2. The exchange rate of points is 3. Query the remaining points 4. Change the password 5. Open a card 6. Exit "); System.out.println ("\ nWhile-"); System.out.println (); System.out.print (" Please select what you want to do: "); choose (sc.nextInt ()) } / * user selected service * @ param num * / public void choose (int num) {switch (num) {case 1: saveScore (); break; case 2: useScore (); break; case 3: search (); break Case 4: updatePwd (); break; case 5: regist (); break; case 6: System.out.println ("Welcome again!") ; System.exit (0); break;} init ();} / * * integral accumulation * / public void saveScore () {Member m = check (); if (masked points null) {System.out.print ("Please enter the amount you consume (one yuan and one credit):") Int score = sc.nextInt (); m.setScore (m.getScore () + score); System.out.println ("points increased successfully, your current points are: + m.getScore ()); System.out.println (" cumulative success! ") ;} else {System.out.println ("cumulative failure of credits, the information you entered is wrong!") ;}} / * points exchange * / public void useScore () {Member m = check (); if (masked points null) {System.out.print ("Please enter the points you need to exchange (100 points against 1 yuan, points less than 100 will not be offset); int score = sc.nextInt () If (m.getScore ()) > = 100 & & score > = 100 & & score

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report