前言
软考考察的特点是广度为主,深度为辅,因此我们需要了解每个知识点的基本概念和原理,而不是过于集中于某一个知识点进行深入研究。而AI最擅长的就是理解和运用知识点,能够帮助我们快速掌握知识点,缩短通关软考周期。
学习环境
- 历年真题
建议使用 APP 刷题,方便记录错题,查看解析,把控进度。
- AI 助手
LLama3 70b Qwen 110b GPT4 都可以,LLama3 思维比较灵活,Qwen 中文训练语料充足,GPT4 是最强王者。
实战演示
下面我以软件设计师考试为例,分别对选择题和案例题进行实战演示。
1. 选择题
选择题命题的趋势是逐步淘汰概念记忆题型,增加计算推理题型。
如下题考察海明码知识点,是典型的计算推理题。
设信息位是8位,用海明码来发现并纠正1位出错的情况,则校验位的位数至少为(3)
A. 1
B. 2
c. 4
D. 8
假设我们不知道这个知识点,就求助AI,来看看它如何进行解答。
非常的详细,推理的过程和计算结果都是正确的,思路十分清晰。
如此一来,我们就掌握了下面的公式。
2
r
≥
n
+
r
+
1
2^r \geq n + r + 1
2r≥n+r+1
2. 案例题
阅读下列说明和 Java 代码,将应填入(n) 处的字句写在答题纸的对应栏内。
【说明】在某系统中,类 Interval 代表由下界(lower bound)和上界(upper bound)定义的区间。要求采用不同的格式显示区间范围。如:[lower bound,upper bound]、[lower bound…upper bound]、[lower bound-upper bound] 等。现采用策略 Strategy 模式实现该要求。
enum TYPE {
COMMA,
DOTS,
LINE
}
interface PrintStrategy {
public (1) ;
}
class Interval {
private double lower;
private double upper;
public Interval(double lower, double upper) {
this.lower = lower;
this.upper = upper;
}
public double getLower() { return lower; }
public double getUpper() { return upper; }
public void printIntervals(PrintStrategy ptr) {
(2) ;
}
}
class PrintIntervalsComma implements PrintStrategy {
public void doPrint(Interval val) {
System.out.println("[" + val.getLower() + "," + val.getUpper() + "]");
}
}
class PrintIntervalsDots implements PrintStrategy {
public void doPrint(Interval val) {
System.out.println("[" + val.getLower() + "..." + val.getUpper() + "]");
}
}
class PrintIntervalsLine implements PrintStrategy {
public void doPrint(Interval val) {
System.out.println("[" + val.getLower() + "-" + val.getUpper() + "]");
}
}
public class Main {
public static PrintStrategy getStrategy(TYPE type) {
PrintStrategy st = null;
switch (type) {
case COMMA:
(3) ;
break;
case DOTS:
(4) ;
break;
case LINE:
(5) ;
break;
}
return st;
}
public static void main(String[] args) {
Interval a = new Interval(1.7, 2.1);
a.printIntervals(getStrategy(TYPE.COMMA));
a.printIntervals(getStrategy(TYPE.DOTS));
a.printIntervals(getStrategy(TYPE.LINE));
}
}
这段代码定义了一个枚举TYPE来表示不同的打印间隔的方式,以及一个接口PrintStrategy用于定义打印策略。Interval类使用了策略模式,通过传入不同的PrintStrategy实例来改变打印间隔的方式。getStrategy方法根据传入的TYPE返回相应的策略实现类的实例。在main方法中,通过这个策略模式实现了对同一个间隔使用不同方式打印的效果。
AI解答如下:
public void doPrint(Interval val);
- This is the method signature for the PrintStrategy interface.
ptr.doPrint(this);
- This calls the doPrint method on the provided PrintStrategy object, passing the current Interval object as an argument.
st = new PrintIntervalsComma( );
- This sets the PrintStrategy object to an instance of PrintIntervalsComma.
st = new PrintIntervalsDots( );
- This sets the PrintStrategy object to an instance of PrintIntervalsDots.
st = new PrintIntervalsLine( );
- This sets the PrintStrategy object to an instance of PrintIntervalsLine.
我们来看看他的解题思路
Here’s my thought process when filling in the blanks:
Step 1: Understanding the problem
I read through the code and understood that it’s a Java program that uses an enum TYPE to represent different types of printing strategies for intervals. There are three types of printing strategies: COMMA, DOTS, and LINE. The program has an interface PrintStrategy that defines a method doPrint(Interval val) to print an interval using a specific strategy.
Step 2: Filling in the ptr.doPrint()
I started by looking at the PrintStrategy interface and saw that it was missing a method signature. I knew that the method should take an Interval object as an argument, so I filled in the blank with public void doPrint(Interval val);.
Next, I looked at the Interval class and saw that it had a method printIntervals(PrintStrategy ptr) that was missing an implementation. I knew that this method should call the doPrint method on the provided PrintStrategy object, passing the current Interval object as an argument. So, I filled in the blank with ptr.doPrint(this);
Step 3: Implementing the printing strategies
I then looked at the three classes that implement the PrintStrategy interface: PrintIntervalsComma, PrintIntervalsDots, and PrintIntervalsLine. Each of these classes had a doPrint method that was correctly implemented to print an interval using the corresponding strategy.
Step 4: Completing the getStrategy method
Finally, I looked at the getStrategy method in the Main class, which was missing implementations for each case of the TYPE enum. I knew that each case should return an instance of the corresponding printing strategy class. So, I filled in the blanks with st = new PrintIntervalsComma();, st = new PrintIntervalsDots();, and st = new PrintIntervalsLine();.
Step 5: Reviewing the code
After filling in all the blanks, I reviewed the code to make sure it made sense and was consistent with the problem statement.
That’s my thought process!