zoukankan      html  css  js  c++  java
  • 03_java基础(五)之项目结构搭建

    1.结构图

       

    2.dao代码编辑

     1 package com.day01.station.dao;
     2 
     3 /**
     4  * Created by Administrator on 2018/2/1.
     5  */
     6 public class ProductDao {
     7     //增加 一个产品 包括 名称 和  卖价
     8     public void save(String productName, int salePrice) {
     9         System.out.println("--------我是增加方法---------");
    10         System.out.println(" productName = " + productName + " , salePrice =" + salePrice);
    11     }
    12 
    13     //删除   根据id删除产品
    14     public void delete(int id) {
    15         System.out.println(" --------我是删除方法--------- ");
    16         System.out.println("---id=" + id);
    17 
    18     }
    19 
    20     //修改  根据id 修改产品的名称
    21     public void update(int id, String productName) {
    22         System.out.println("--------我是修改方法---------");
    23         System.out.println(" productName = " + productName + " , id =" + id);
    24     }
    25 
    26     //查询
    27     public String query() {
    28         System.out.println("------我是查询方法----------");
    29         return "苹果手机";
    30     }
    31     
    32 }

    3.测试代码编辑

     1 package com.day01.station.testDao;
     2 
     3 import com.day01.station.dao.ProductDao;
     4 import org.junit.Test;
     5 
     6 /**
     7  * Created by Administrator on 2018/2/1.
     8  */
     9 public class TestProductDao {
    10     /**
    11      * 测试保持方法
    12      */
    13     @Test
    14     public void testSave(){
    15         //不同的类里面如何调用方法
    16           //1.先拿到 对象   new 对象
    17             //  x=2
    18             //  int age=18
    19         ProductDao productDao = new ProductDao();
    20         //2. 用  对象.方法
    21         productDao.save("苹果手机",8888);
    22     }
    23     @Test
    24     public void testDelete(){
    25         //1.拿到  dao对象
    26         ProductDao productDao = new ProductDao();
    27         //2.调用dao对象的方法
    28         productDao.delete(12);
    29 
    30     }
    31     @Test
    32     public void testUpdate(){
    33         //1.拿到  dao对象
    34         ProductDao productDao = new ProductDao();
    35         //2.调用dao对象的方法
    36         productDao.update(14,"华为手机");
    37 
    38     }
    39     @Test
    40     public void testQuery(){
    41         //1.拿到  dao对象
    42         ProductDao productDao = new ProductDao();
    43         //2.调用dao对象的方法
    44         String query = productDao.query();
    45         System.out.println("query="+query);
    46     }
    47 }

    4.

  • 相关阅读:
    设置一个字符串中的个别字符的特殊格式
    在代码中设置字体加粗的方法
    删除字符串中某字符
    xib下这种方式创建cell
    UILabel 字体下方加下划线
    iPhone4 8.3 系统下字体下方去除下划线
    elasticsearch 深入 —— normalizer
    elasticsearch 基础 —— Common Terms Query常用术语查询
    elasticsearch 基础 —— Jion父子关系
    elasticsearch 深入 —— Top Hits Aggregation
  • 原文地址:https://www.cnblogs.com/newAndHui/p/8401045.html
Copyright © 2011-2022 走看看