Team Fast & Furious:Extreme Programming

832101120郑梓欣 2023-11-19 23:37:25

 

Team :Fast & Furious

Team memberstudent IDDivision of labor
张佳卉832101214Login and registration interface
王鑫瑜832101203Login and registration interface
卞晴832101204Login and registration interface
陈璐歆832101316scientific calculator
陈俪文832101315scientific calculator
黄阳烁832101124

Interest rate calculator

高畅832101323

Interest rate calculator

林璟玟832101318Establish GitHub team repository
郑梓欣832101120blogging
Team member张佳卉832101214王鑫瑜832101203卞晴832101204陈璐歆832101316陈俪文832101315黄阳烁832101124高畅832101323林璟玟832101318郑梓欣832101120
score1091191114131310

 

Scientific Calculator functions:

js:
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>CalBeta</title>

    <link rel="stylesheet" href="./cal.css">
    <style>
    </style>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
    </script>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>


</head>

<body>

    <div class="calculator" id="app" style="background-color: green;">
        <input type="text" v-model="infos" class="display" disabled>

        <button @click="getNumber1('(')">(</button>
        <button @click="getNumber1(')')">)</button>
        <button @click="getOperator('%')">%</button>
        <button @click="clearDisplay()">C</button>

        <button @click="getNumber1('sin(')">sin</button>
        <button @click="getNumber1('cos(')">cos</button>
        <button @click="getNumber1('tan(')">tan</button>
        <button @click="def">deg</button>

        <button @click="getNumber('7')">7</button>
        <button @click="getNumber('8')">8</button>
        <button @click="getNumber('9')">9</button>
        <button @click="getOperator('/')">/</button>

        <button @click="getNumber('4')">4</button>
        <button @click="getNumber('5')">5</button>
        <button @click="getNumber('6')">6</button>
        <button @click="getOperator('*')">*</button>

        <button @click="getNumber('1')">1</button>
        <button @click="getNumber('2')">2</button>
        <button @click="getNumber('3')">3</button>
        <button @click="getOperator('-')">-</button>

        <button @click="getNumber('0')">0</button>
        <button @click="getNumber('.')">.</button>
        <button @click="calculate">=</button>
        <button @click="getOperator('+')">+</button>



    </div>

    <script src="./calBeta.js"></script>

    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!',
                firstnum: "",
                endnum: "",
                operator: "",
                fscod: true,
                infos:"",
                listNum:1

            },
            methods: {
                def(){
                    this.getList(this.listNum)
                },
                clearDisplay() {
                    this.infos = "";
                    this.firstnum = "";
                    this.endnum = ""
                },
                getNumber(e) {
                    if (this.fscod) {
                        this.firstnum += e+""
                        this.infos =  this.firstnum + ""
                    }else{
                        this.endnum += e+""
                        this.infos = this.firstnum+this.operator + ""+ this.endnum + ""
                    }

                    console.log("111", e)
                },
                getNumber1(e) {
                    console.log("222", e)
                },
                getOperator(e) {
                    this.fscod = false
                    this.operator = e
                    console.log("333", e)
                    this.infos =  this.firstnum+this.operator+""
                },


                calculate() {
                    var  that = this
                    $.ajax({
                        url: 'http://localhost:8081/jisuanji/jisuan',// 请求的URL
                        method: 'GET', // 请求方法(GET、POST等)
                        dataType: 'text',
                        async: "true",
                        data:{
                            number1:this.firstnum,
                            number2:this.endnum,
                            type:this.operator
                        },
                        success: function (response) {
                            that.infos = response// 请求成功时的回调函数
                            that.firstnum = ""
                            that.endnum = ""
                            that.operator = ""
                            that.fscod=true
                            that.listNum = 1
                            console.log(response); // 打印服务器返回的数据
                        },
                        error: function (xhr, status, error) { // 请求失败时的回调函数
                            console.log('请求失败');
                            console.log(xhr);
                            console.log(status);
                            console.log(error);
                        }
                    });

                },
                getList(str) {
                    var  that = this
                    $.ajax({
                        url: 'http://localhost:8081/jisuanji/list',// 请求的URL
                        method: 'GET', // 请求方法(GET、POST等)
                        dataType: 'json',
                        async: "true",
                        data:{
                            str:str
                        },
                        success: function (response) {
                            // 请求成功时的回调函数
                            that.fscod=true
                            that.listNum += 1
                            that.infos =response.jg + ""
                            console.log(that.infos); // 打印服务器返回的数据
                        },
                        error: function (xhr, status, error) { // 请求失败时的回调函数
                            console.log('请求失败');
                            console.log(xhr);
                            console.log(status);
                            console.log(error);
                        }
                    });

                }
            }
        });
    </script>

</body>

</html>
<style>

    .calculator {
        width: 400px;
        margin: 0 auto;
        padding: 20px;
        background: #ddd;
        border-radius: 10px;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-gap: 5px;
    }

    .display {
        grid-column: span 4;
        height: 50px;
        font-size: 20px;
        margin-bottom: 10px;
        padding: 5px;
        border: none;
        background: #fff;
        height: 120px;
    }

    button {
        width: 100%;
        height: 40px;
        font-size: 14px;
        margin: 5px;
        border-radius: 5px;
        border: none;
        background: #ffffff;
        cursor: pointer;
    }
</style>
java:

package com.jisuanji.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jisuanji.config.jisuan;
import com.jisuanji.entity.JsjHistory;
import com.jisuanji.service.IJsjHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**

 */
@RestController
@RequestMapping("/jisuanji")
public class JsjHistoryController {
    @Autowired
    IJsjHistoryService iJsjHistoryService;
    @RequestMapping("/list")
    public JsjHistory list(String str){
        QueryWrapper<JsjHistory> queryWrapper = new QueryWrapper<>();
        QueryWrapper<JsjHistory> queryWrapper1 = queryWrapper.orderByDesc("id");
        List<JsjHistory> list = iJsjHistoryService.list(queryWrapper1);
        Map<String,JsjHistory> map = new HashMap<>();
        for (int i = 1; i <= list.size(); i++) {
            map.put(i+"",list.get(i-1));
        }
        JsjHistory jsjHistory = map.get(str);
        return  jsjHistory;
    }
    @RequestMapping("/jisuan")
    public String jisuan(String number1,String number2,String type) throws Exception {
        jisuan js = null;
        if (type.equals("+")){
            js = new add();
        } else if (type.equals("-")) {
            js = new subtract();
        } else if (type.equals("*")) {
            js = new multiply();
        }else if (type.equals("/")){
            js = new divide();
        }
        else if (type.equals("%")){
            js = new yu();
        }else {
            throw new Exception("计算方式输入错误");
        }
        String jisuan = js.jisuan(number1, number2);
        JsjHistory jsjHistory = new JsjHistory();
        jsjHistory.setType(type);
        jsjHistory.setNumber1(number1);
        jsjHistory.setNumber2(number2);
        jsjHistory.setJg(jisuan);
        iJsjHistoryService.save(jsjHistory);
        return jisuan;

    }
}
class add implements jisuan{
    @Override
    public String jisuan(String number1, String number2) {
        BigDecimal bigDecimal = new BigDecimal(number1);
        BigDecimal bigDecimal1 = new BigDecimal(number2);
        BigDecimal add = bigDecimal.add(bigDecimal1);
        return add.toString();
    }
}
class subtract implements jisuan{

    @Override
    public String jisuan(String number1, String number2) {
        BigDecimal bigDecimal = new BigDecimal(number1);
        BigDecimal bigDecimal1 = new BigDecimal(number2);
        BigDecimal add = bigDecimal.subtract(bigDecimal1);
        return add.toString();
    }
}
class multiply implements jisuan{

    @Override
    public String jisuan(String number1, String number2) {
        BigDecimal bigDecimal = new BigDecimal(number1);
        BigDecimal bigDecimal1 = new BigDecimal(number2);
        BigDecimal add = bigDecimal.multiply(bigDecimal1);
        return add.toString();
    }
}
class divide implements jisuan{

    @Override
    public String jisuan(String number1, String number2) {
        BigDecimal bigDecimal = new BigDecimal(number1);
        BigDecimal bigDecimal1 = new BigDecimal(number2);
        BigDecimal add = bigDecimal.divide(bigDecimal1,8,BigDecimal.ROUND_HALF_UP);
        return add.toString();
    }
}
class yu implements jisuan{

    @Override
     public String jisuan(String number1, String number2) {
       int a =  Integer.parseInt(number1)%Integer.parseInt(number2);
        return a+"";
    }
}

 

 Interest rate calculator:

Backend: Define a route for processing POST requests to receive computing requests:

@app.route('/t/calculate', methods=['POST'])
def calculator():
    data = request.get_json()  # 获取来自前端的 JSON 数据
    evalString = data['expression']  
    displayString = calculate_expression(evalString)  
    cursor.execute("INSERT INTO calculations (expression, result) VALUES (%s, %s)", (evalString, displayString))  
    conn.commit()  
 
    return jsonify({'status': 'success'})

 Define a route for processing GET requests to obtain calculation records:

@app.route('/t/calculate-records', methods=['GET'])
def get_calculation_records():
    cursor.execute("SELECT expression, result FROM calculations ORDER BY id DESC LIMIT 10")
    records = cursor.fetchall()
 
    response = []
    for record in records:
        expression, result = record
        response.append({'expression': expression, 'result': result})
 
    return jsonify(response)

 Using a function to calculate the expression returned by the front-end:

def calculate_expression(expression):
    try:
        expression = expression.replace("π", str(math.pi))
        expression = expression.replace("e", str(math.e))
        result = eval(expression)
        return result
    except Exception as e:
        print("计算错误:", str(e))
        return None

 Front end:

var requestData = {
      expression: expression
    };
 
    fetch('/t/calculate', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(requestData)
    })
      .then(response => response.json())
      .then(data => {
         show(data.result);
        console.log(data);
      })
      .catch(error => {
        console.error('Error:', error);
      });
  } catch {
    show("error");
  }
}

 Read the history of the calculator and click the "ans" button to obtain the latest calculation record:

$(".operators[value='ans']").click(function() {
  fetch('/t/calculate-records')
  .then(response => response.json())
  .then(data => {
      const List = document.getElementById('records-container');
      List.innerHTML = '';
      data.forEach(record => {
      const calculationItem = document.createElement('li');
      calculationItem.textContent =record.expression +"="+ record.result;
      List.appendChild(calculationItem);
      });
   });
});

 Used to clear the display interface:

function clr() {
  displayString = "0";
  evalString = "0";
  show(displayString); // 更新显示区域
}

Login interface:

from flask import Flask, render_template,request
import pymysql



app = Flask(__name__)

@app.route("/add/user",methods=["GET","POST"])
def test():
    if request.method=="GET":
        return  render_template("login.html")
    u1 = request.form.get("email")

    u2 = request.form.get("password")
    conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
    # 创建游标
    cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
    # 插入
    sql = "insert into user1(email,password)values(%s,%s)"
    cursor.execute(sql, [u1,u2])
    conn.commit()

    cursor.close()
    conn.close()
    return render_template("calculator.html")
app.route("/show/user")
def show():
    conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
    # 创建游标
    cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

    # 查询
    sql="select*from user1"
   # cursor.execute(sql)
    #data=cursor.fetchall()

    #cursor.close()
    #conn.close()




if __name__ == "__main__":
    app.run()

GitHub:

https://github.com/ilemontea/teamwork/tree/main
 

PSP

张佳卉

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150120
Analysis3030
Design Spec2040
Design Review4030
Coding Standard3020
 Design5060
Coding120100
Code Review1020
Test3020
Reporting1010
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum570530

 

王鑫瑜

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150120
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding120100
Code Review1020
Test3020
Reporting00
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum560500

卞晴

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 2020
Estimate1010
Development150120
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding120100
Code Review1020
Test3020
Reporting00
Test Report00
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum540480

陈璐歆

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150120
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding150150
Code Review1020
Test3020
Reporting00
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum590550

陈俪文

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150180
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding120100
Code Review1020
Test3020
Reporting1010
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum570570

黄阳烁

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150120
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding160170
Code Review1020
Test3020
Reporting00
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum600570

高畅

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 2020
Estimate1010
Development180170
Analysis3030
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding160150
Code Review1020
Test3020
Reporting00
Test Report1010
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum620590

林璟玟

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development10090
Analysis8080
Design Spec2020
Design Review9080
Coding Standard3020
 Design5060
Coding120100
Code Review5050
Test4040
Reporting00
Test Report00
Size Measurement1010
Postmortem & Process Improvement Plan2020
Sum630610

郑梓欣

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning 3030
Estimate1010
Development150120
Analysis5040
Design Spec2020
Design Review4030
Coding Standard3020
 Design5060
Coding3030
Code Review1020
Test3020
Reporting1020
Test Report1010
Size Measurement7080
Postmortem & Process Improvement Plan6060
Sum560570

 

...全文
31 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

174

社区成员

发帖
与我相关
我的任务
社区描述
梅努斯软件工程
软件工程 高校 福建省·福州市
社区管理员
  • LinQF39
  • Jcandc
  • 助教-陈锦辉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧