Android 第3天 类的复习 图书管理 及 SQLite 基本语法
来源:互联网 发布:阿里云给我打电话 编辑:程序博客网 时间:2024/05/21 11:08
Book 类
public class Book {
String nostring;
String namestring;
int price;
public static void main(String[] args) {
}
}
manger 类
public class Manger {
Book [] books=new Book[10];
public void add(String no,String name, int price) {
// TODO Auto-generated method stub
Book b=new Book();
b.nostring=no;
b.namestring=name;
b.price=price;
for(int i=0;i<books.length;i++){
if(books[i]==null){
books[i]=b;
break;
}
}
}
public void update(String no,String name, int price) {
for(int i=0;i<books.length;i++){
if(books[i]!=null){
if(no.equals(books[i].nostring)){
books[i].namestring=name;
books[i].price=price;
}
}
}
}
public void show() {
for(int i=0;i<books.length;i++){
if(books[i]!=null){
System.out.println(books[i].nostring+"\t"+books[i].namestring+"\t"+books[i].price);
}
}
}
public void byno(String no){
for(int i=0;i<books.length;i++){
if(books[i]!=null){
{ if(no.equals(books[i].nostring))
System.out.println(books[i].nostring+"\t"+books[i].namestring+"\t"+books[i].price);
}
}
}
}
}
menu类
import java.util.*;
public class Menu {
Manger m=new Manger();
Scanner s =new Scanner(System.in);
public void add(){
System.out.println("no");
String no=s.next();
System.out.println("name");
String name=s.next();
System.out.println("price");
int price=s.nextInt();
m.add(no,name,price);
}
public void update(){
System.out.println("no");
String no1=s.next();
System.out.println("name");
String name1=s.next();
System.out.println("price");
int price1=s.nextInt();
m.update(no1,name1,price1);
}
public void show(){
m.show();
}
public void byno(){
System.out.println("no");
String no3=s.next();
m.byno(no3);
}
}
登陆类
import java.util.*;
public class Login {
String name="admin";
String password="12345";
public boolean denglu(){
Scanner s =new Scanner(System.in);
System.out.println("输入姓名");
String name=s.next();
System.out.println("密码");
String p=s.next();
if(name.equals(Login.this.name)&&p.equals(Login.this.password)){
System.out.println("登陆成功");
return true;
}
else { System.out.println("登录失败");
return false;}
}
}
主函数 test
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Menu m=new Menu();
Login l=new Login();
Scanner s =new Scanner(System.in);
while( l.denglu()){
System.out.println("选择功能:1.修改登录密码2管理图书");
switch(s.nextInt()){
case 1:
System.out.println("输入新的密码");
l.password=s.next();
System.out.println("修改成功,请重新登录");
//System.exit(0);
break;
case 2: while(true){
System.out.println("1.add 2.update 3.show.4byno5.exit");
switch(s.nextInt()){
case 1:
m.add();
break;
case 2:
m.update();
break;
case 3:
m.show();
break;
case 4:
m.byno();
break;
case 5:
System.exit(0);
default:break;
}
// default:break;
}
}
}
}
}
SQLite 基本语法
drop table goods
create table goods (id int(8),name vachar(100),type vachar(50),count int(4),price double(6));
insert into goods values(1001,'小熊饼干', '食物', 50, 2.8);
insert into goods values(1002, '桃李面包','食物',24,3.5);
insert into goods values(1003, '牛奶','食物', 50,9);
insert into goods values(1003, '火腿肠','食物', 20,2.5);
select name ,price from goods;
- Android 第3天 类的复习 图书管理 及 SQLite 基本语法
- Android SQLite数据库基本语法
- 在Linux下,用SQlite数据库编写的图书管理系统源代码及错误总结
- SQLite-基本语法整理-3
- 第18天 jdk5.0新特性及图书管理系统
- 第二章 SQLite的基本语法
- Android数据库Sqlite的基本用法及升级策略
- c# 基本语法复习
- js复习之-基本语法及数据类型
- sqlite 基本语法
- SQLite基本语法手册
- SQLite基本语法
- SQL基本语法&SQLite
- SQLite数据库基本语法
- SQLite基本语法
- Android的SQLite基本操作
- Android Sqlite的基本用法
- Android SQLite的基本操作
- Android生成随机验证码
- HDU 1271 整数对-组合数学
- ionic的header颜色设置
- poj 3207 Ikki's Story IV - Panda's Trick 【2-sat 经典建模】
- 讨论“get”和“post”安全性
- Android 第3天 类的复习 图书管理 及 SQLite 基本语法
- hdu 5289 Assignment(2015多校第一场第2题)RMQ+二分(或者multiset模拟过程)
- OC_字典
- 菜鸟系列——搜索
- java GC性能优化
- Redhat6.5 配置使用centos的yum源
- 2502 月之数
- 最新Spring集成MyBatis详细教程(一)--ccw
- 将button的click事件作为判断条件