首页 > 其他分享 >题目集4,5的总结性blog

题目集4,5的总结性blog

时间:2023-07-01 20:14:51浏览次数:47  
标签:总结性 题目 temp str1 blog token continue println out

前言:

题目集4和5 的知识点、题量、难度等情况如下:

  • 知识点:JAVA基础,基础算法,面向对象程序设计

  • 题量:共计 2 道题目

  • 难度:题目较难,有挑战性和突破性

设计与分析:

本次 Blog 重点分析成绩计算系列题目,即题目集 4的 7-1、题目集5的7-1。这两道题都是计价系统的迭代,延用前几次题目集的设计与分析

  • 题目集4的7-1在之前的基础上增加了许多报错信息 和一个特色菜系统

    //特色菜系统,由输入格式判断输入的是否为特色菜,若是则存储的时候改变IsT变量以供后续识别
    if (str1.matches("[\\S]* [\\d]* T")) {
                    String[] token = str1.split(" ");
                    temp.name = token[0];
                    temp.unit_price = Integer.parseInt(token[1]);
                    if (temp.unit_price > 300) {
                        System.out.println(temp.name + " price out of range " + temp.unit_price);
                        continue;
                    }
                    temp.isT = true;
                    isRepeat = menu.searchDish(temp.name);
                    if (isRepeat != -1) {
                        menu.dishs.remove(isRepeat);
                    }
                    menu.dishs.add(temp);
    //信息的读入以及时间系统的创建和报错
    if (str1.matches(
                            "table [1-9][\\d]* [\\d]*/[\\d][\\d]?/[\\d][\\d]? [\\d][\\d]?/[\\d][\\d]?/[\\d][\\d]?")) {
                        String[] token = str1.split(" ");
                        String[] Date = token[2].split("/");
                        String[] Time = token[3].split("/");
                        int[] intDate = new int[3];
                        int[] intTime = new int[3];
                        for (i = 0; i < 3; i++) {
                            intDate[i] = Integer.parseInt(Date[i]);
                            intTime[i] = Integer.parseInt(Time[i]);
                        }
                        temp.num = Integer.parseInt(token[1]);
                        if (temp.num > 55) {
                            System.out.println(temp.num + " table num out of range");
                            str1 = input.nextLine();
                            continue;
    
                        }
                        try {
                            temp.time = LocalDateTime.of(intDate[0], intDate[1], intDate[2], intTime[0], intTime[1],
                                    intTime[2]);
                            temp.getWeekDay();
                        } catch (DateTimeException e) {
                            System.out.println(temp.num + " date error");
                            str1 = input.nextLine();
                            continue;
                        }
                        if (!temp.isOpen()) {
                            System.out.println("table " + temp.num + " out of opening hours");
                            str1 = input.nextLine();
                            continue;
                        }
                        if (!(temp.time.isAfter(LocalDateTime.of(2022, 1, 1, 0, 0, 0))
                                && temp.time.isBefore(LocalDateTime.of(2024, 1, 1, 0, 0, 0)))) {
                            System.out.println("not a valid time period");
                            str1 = input.nextLine();
                            continue;
                        }
    // 判断桌号是否重复
                        if (temp.isOpen()) {
                            for (i = 0; i < tables.size(); i++) {
                                // 有重复的桌号
                                if (temp.num == tables.get(i).num && tables.get(i).isOpen()) {
                                    Duration duration = Duration.between(temp.time, tables.get(i).time);
                                    // 同一天
                                    if (duration.toDays() == 0) {
                                        // 在周一到周五
                                        if (temp.weekday > 0 && temp.weekday < 6) {
                                            // 在同一时间段
                                            if (temp.time.getHour() < 15 && tables.get(i).time.getHour() < 15) {
                                                isRepeat = true;
                                                repeatNum = i;
                                                break;
                                            }
                                        }
                                        // 在周末
                                        else {
                                            // 时间相差小于一小时
                                            if (duration.toHours() < 3600) {
                                                repeatNum = i;
                                                isRepeat = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
    //各类报错信息
    if (temp.order.records.size() > 0) {
                                if (Integer.parseInt(
                                        token[0]) <= temp.order.records.get(temp.order.records.size() - 1).orderNum) {
                                    System.out.println("record serial number sequence error");
                                    continue;
                                }
                            }
                            if (menu.searchDish(token[1]) == -1) {
                                System.out.println(token[1] + " does not exist");
                                continue;
                            }
                            if (portion > 3 || portion < 1) {
                                System.out.println(Integer.parseInt(token[0]) + " portion out of range " + portion);
                                continue;
                            }
                            if (quota > 15) {
                                System.out.println(Integer.parseInt(token[0]) + " num out of range " + quota);
                                continue;
                            }
    // 判断是否为夹杂菜单
                        else if (str1.matches("[\\S]* [\\d]*")) {
                            System.out.println("invalid dish");
                            continue;
                        } else if (str1.matches("[\\S]* [\\d]* T")) {
                            System.out.println("invalid dish");
                            continue;
                        }

     

  • 第五次题目集为第三次题目集的不同迭代分支,与第四次不同,因此应在第三次题目集的代码上做修改
  • 本分支着重了第四次题目集中的特色菜系统
    //新的特色菜系统
    if (str1.matches("[\\S]* [\\S]* [\\d]* T")) {
                    String[] token = str1.split(" ");
                    temp.name = token[0];
                    temp.unit_price = Integer.parseInt(token[2]);
                    temp.isT = true;
                    switch (token[1]) {
                    case "川菜":
                        temp.FlavorType = "spicy";
                        temp.MaxFlavor = 5;
                        break;
                    case "晋菜":
                        temp.FlavorType = "acidity";
                        temp.MaxFlavor = 4;
                        break;
                    case "浙菜":
                        temp.FlavorType = "sweetness";
                        temp.MaxFlavor = 3;
                        break;
                    default :str1 = input.nextLine();
                    System.out.println("wrong format");
                    continue;
                            
                    }
                    isRepeat = menu.searchDish(temp.name);
                    if (isRepeat != -1) {
                        menu.dishs.remove(isRepeat);
                    }
                    menu.dishs.add(temp);
                }

     

  • 第八次题目集的7-2:新增了每次成绩的占比,改变了原有的计算成绩方式,要求将每次成绩计算的小数点保留后累加,最后舍弃小数位。实验课程的信息输入模式也进行了一些修改。需要将原有的类进行修改 复制代码
    //对原本的课程输入函数进行修改
    if (str1.matches ("[\\D]{0,11} [\\S]+ [\\S]+ .*")) {
                    String[] token = str1.split (" ");
                    if (!(token[1].equals ("必修") || token[1].equals ("选修") || token[1].equals ("实验"))) {
                        System.out.println ("wrong format");
                        str1 = input.nextLine ();
                        continue;
                    }
                    if (!(token[2].equals ("考试") || token[2].equals ("考察") || token[2].equals ("实验"))) {
                        System.out.println ("wrong format");
                        str1 = input.nextLine ();
                        continue;
                    }
                    if (schedule.searchCourseByName (token[0]) != -1) {
                        str1 = input.nextLine ();
                        continue;
                    }
                    schedule.addACourse (token);
                    str1 = input.nextLine ();
                }
    
    
    
    
    
    
    //对课程信息的输出函数进行修改
    public void showEndScores () {
            courses.sort (new Comparator<Course> () {
                @Override
                public int compare (Course o1, Course o2) {
                    Collator collator = Collator.getInstance (java.util.Locale.CHINA);
                    return collator.compare (o1.name, o2.name);
                }
            });
            for (int i = 0; i < courses.size (); i++) {
                courses.get (i).showEndScore ();
            }
        }
    复制代码

标签:总结性,题目,temp,str1,blog,token,continue,println,out
From: https://www.cnblogs.com/kuangyv/p/17519827.html

相关文章

  • C/C++《数据结构课程设计》题目[2023-07-01]
    C/C++《数据结构课程设计》题目[2023-07-01]《数据结构课程设计》题目一、【大数四则运算】——线性表[习题描述]设计—个实现任意长的整数进行四则运算和幂次运算的演示程序。[基本要求]利用双向循环链表实现大数的存储,每个结点含一个整型变量。[实现提示]实现原理:任何一......
  • 天津大学夏令营机试题目
    首先我没参加机试,所以我都是口胡的做法,大概率能对吧   简单模拟,双指针或者什么的搞一搞,使用getline输入strings;intn;voidwork(){getline(cin,s);n=s.length();for(inti=0;i<n;i++){intj=i;while(j+1<n&&s[j+1]==s[i])......
  • pta题目集4-5及期中考试
    1.前言:点菜程序,光是听到名字就让人颤栗,我也光荣的基本上没写出来,以下的代码是题目集结束之后写出来的pta题目集4:7-1菜单计价程序-4分数 100 全屏浏览题目切换布局作者 蔡轲单位 南昌航空大学 本体大部分内容与菜单计价程序-3相同,增加的部......
  • PTA题目集4、5以及期中考试
    前言在这篇Blog中,我将总结之前所涉及到的PTA题目集4、5以及期中考试的情况。这些题目涉及了不同的知识点和题量,并具有一定的难度。本次Blog的重点将分析PTA中的菜单计价系列的题目以及期中考试的题目。设计与分析菜单计价系列题目分析菜单计价系列的题目要求设计一个点菜计价......
  • PTA题目集4、5以及期中考试的总结性Blog
    一、前言第4、5次大作业只有一题菜单的迭代,虽然题目量不多,但是难度却是大大增加,更加考验大家的学习自觉性和Java的功底,这两次的大作业均是在菜单系列-3的基础上迭代,是菜单系列-3的两个不同分支。自然而然,与菜单系列-3的代码结构的完整性和可复用性等关联就很大,菜单系......
  • 第四、五次题目集以及期中考试总结
    第四、五次题目集以及期中考试总结一、题目集四第一题题目内容:菜单计价程序-4**importjava.util.*;publicclassMain{publicstaticvoidmain(String[]args){Restaurantres=newRestaurant();res.start();}}importjava.util.Arr......
  • BLOG-2
    前言 知识点:期中考试主要考察了,继承,抽象类,多态,Comparable接口题量:还可以难度:很简单设计与分析菜单4类图                                      ......
  • 4-5题目集及期中
    前言:第四次题目集的知识点涉及Time类以及前面学的各种知识点;题量很少只有一题;难度比较大。第五次题目集的知识点主要是Time类、异常处理等等;题量很少只有一题;难度比较大。期中考试的知识点涉及类、继承与多态、接口等等;题量不多,一共4题;整体难度不高。第四次题目集7-1菜单计价......
  • BLOG-2
    一.前言1.第四次题目集①知识点:啥都考了。②题量:少。③难度:很难。2.第五次题目集①知识点:啥都考了。②题量:少。③难度:难上加难。3.期中考试①知识点:Java基础语法:例如变量定义、常量定义、数据类型、循环、条件语句等。 面向对象编程:例如类和对象的定义,封装、继承和多态......
  • PTA 4,5题目集及期中考试总结
    PTA4,5题目集及期中考试总结前言第4次题目集知识点:对象和类的创建和应用,字符串的创建和应用。总共有1题,难度偏高。第5次题目集知识点:对象和类的创建和应用,字符串的创建和应用。总共有1题,难度偏高。期中考试知识点:字符的处理,类的封装,接口的创建和使用。总共有4题,难度偏低......