Analysis of software designer test questions and answers in the first half of 2023

Please click ↑ to follow and bookmark , this blog will provide you with wonderful knowledge sharing for free ! There is a surprise! !

In a computer, the system bus is used for (1) connections.

(1) A. Interface and peripherals 

B. Arithmetic Units, Controllers, and Registers

C. CPU, main memory and peripheral components 

D. DMA controller and interrupt controller

In the three-level storage system consisting of cache, main memory and hard disk, the CPU needs to read data when executing instructions, then the data address issued by the DMA controller and the CPU is (2).

(2) A. Cache address

 B. Main memory physical address

C. The sector address of the hard disk

 D. Virtual address

Assuming that the information bits are 8 bits, and using the Hamming code to find and correct the error of 1 bit, the number of check bits is at least (3).

(3)  A. 1       B. 2        C. 4       D. 8

The interrupt vector provided is (4).

(4) A. The device address of the interrupt source

 B. The entry address of the interrupt service routine

C. The starting address of the transferred data

 D. The breakpoint address of the main program

In computer systems, fixed-point numbers are often represented by complement codes. In the following description about complement code representation, the error is (5).

(5) A. The representation of the complement zero is unique

 B. Can convert subtraction operation into addition operation

C. The sign bit can participate in the operation together with the value bit

 D. The correspondence with the true value is simple and intuitive

Assuming that the instruction pipeline divides the execution of an instruction into three stages: fetching, analyzing, and executing, it is known that the fetching time is 2ns, the analysis time is 2ns, and the execution time is 1ns, then the time required to execute 1000 instructions is (6 ).

(6) A. 1004ns       B. 1998ns         C. 2003ns       D. 2008ns

In the OSI reference model, the layer responsible for compressing and encrypting the application layer messages is (7).

(7) A. Transport layer B. Session layer       C. Presentation layer       D. Application layer

In the PKI system, HTTPS applications are implemented by SSL/TSL. The method used to encrypt HTTP messages between the browser and the server is (8), and the consequences if the server certificate is revoked are (9).

(8) A. The other party's public key + public key encryption

 B. Local public key + public key encryption

C. Session key + public key encryption

 D. Session key + symmetric encryption

(9) A. The server cannot perform encryption and decryption 

B. The server cannot perform the signature

C. The client can no longer trust the server 

D. The client cannot send encrypted information to the server

Which of the following statements about intrusion prevention system functions is incorrect is (10).

(10) A. Monitor and analyze user and system network activities

B. Match signature database to identify known network attack behavior

C. Linkage intrusion detection system to block network attacks

D. Detect zombie host behaviors such as botnet and Trojan horse control

Web application firewalls do not protect effectively (11) .

(11) A. Login password brute force cracking

 B. Malicious registration

C. Ticket grabbing robot

 D. Malware

In copyright (12), the term of protection is unlimited.

(12) A. Right of publication B. Right of distribution C. Right of exhibition       D. Right of authorship

The main way to protect computer software intellectual property from infringement internationally is to implement (13).

(13) A. Contract Law B. Property Law      C. Copyright Law        D. Criminal Law

Among the following statements about computer software copyright, the incorrect one is (14).

(14) A. The software copyright owner can authorize others to exercise its software copyright and has the right to receive remuneration

B. Software copyright owners may transfer all or part of their software copyrights and have the right to receive remuneration

C. If the software copyright belongs to a natural person, after the death of the natural person, within the protection period of the software copyright, the heir can inherit all the rights of the software copyright

D. In order to learn and research the design ideas and principles contained in the software, use the software by installing, displaying, transmitting or storing the software, etc., without the permission of the software copyright owner, and without paying remuneration to him

In the following statement about the basic processing of data flow graphs, (15) is incorrect.

(15) A. For each basic processing, there must be a processing specification

B. The processing specification must describe the processing rules that transform the input data stream into the output data stream

C. Processing specifications need to give the details of the processing

D. Decision trees and decision tables can be used to represent processing specifications

Which of the following statements about good software design principles is incorrect is (16).

(16) A. Modularity 

B. Improve module independence

C. Centralization 

D. Increase the level of abstraction

The figure below is an activity graph of a software project, where the vertices represent the project milestones, and the edges connecting the vertices represent the contained activities, then the milestone (17) is on the critical path, and the critical path length is (18).

(17) A. B        B. E        C. G         D. I

(18) A. 15      B. 17       C. 19       D. 23

There are (19) communication paths in a development team of 8 members.

(19) A. 64      B. 56      C. 32       D. 28

When evaluating the Boolean expression "a or ((b < c) and d)", a short-circuit calculation can be performed when (20).

(20)  A. a is true       B. b is true C. c is true D. d is true

Assuming that the regular formula s = (0 | 10)*, then the characteristic of the character font in the regular set described by it is (21) .

(21) A. The length must be an even number

 B. The length must be an odd number

C. 0 cannot appear consecutively

 D. 1 cannot appear consecutively

Suppose the definitions of functions foo and hoo are as shown in the figure below, call function hoo in function foo, the first parameter of hoo adopts the method of passing reference (call by reerence), and the method of second parameter passing value (call by value), then print(a, b) in function foo will output (22).

(22) A. 8, 5      B. 39, 5      C. 8, 40      D. 39, 40

A file management system uses a bitmap to record disk usage. If the word length of the computer system is 64 bits, the disk capacity is 512GB, and the physical block size is 4MB, then the size of the bitmap is (23) words.

(23) A. 1024     B. 2048       C. 4096       D. 9600

Disk scheduling is divided into two types: arm-moving scheduling and rotating scheduling. In the algorithm of arm-moving scheduling, (24) the algorithm may change the running direction of the moving arm at any time.

(24) A. One-way scanning and first-come, first-served

 B. Elevator Scheduling and Shortest Seek Time First

C. Elevator Scheduling and Shortest Seek Time Priority

 D. First come first serve and shortest seek time first

In an operating system that supports multithreading, assuming that process P creates threads T1, T2, and T3, then (25) .

(25) A. The code segment of this process cannot be shared by T1, T2, and T3

B. The global variables of the process can only be shared by T1

C. The stack pointers of T1, T2, and T3 in this process cannot be shared

D. The stack pointer of T1 in this process can be shared by T2 and T3

The predecessor graphs for processes P1, P2, P3, P4, P5, and P6 are shown below.

If PV operations are used to control the concurrent execution of processes P1, P2, P3, P4, P5, and P6, semaphores S1, S2, S3, S4, S5, S6, S7, and S8 need to be set, and the initial values ​​of semaphores S1~S8 Values ​​are all equal to zero. During the execution of the process of P1~P6 below, empty ① and empty ② should be (26) respectively, empty ③ and empty ④ should be (27) respectively, empty ⑤ and empty ⑥ should be (28) respectively.

(26) A. P(S1)P(S2) and V(S3)V(S4) 

B. P(S1)P(S2) and V(S1)V(S2)

C. V(S3)V(S4) and P(S1)P(S2)

 D. V(S3)V(S4) and P(S2)P(S3)

(27)  A. V(S5) and P(S4)P(S5)

 B. V(S3) and P(S4)V(S5)

C. P(S5) and V(S4)V(S5)

 D. P(S3) and P(S4)P(S5)

(28) A. V(S6) sum V(S8)

 B. P(S6) and P(S7)

C. P (S6) and V (S8) 

D. P(S8) and P(S8)

Which of the following statements about the advantages of the incremental model is incorrect is (29).

(29) A. Able to submit a usable product system in a short time

B. Can make users familiar with the system as early as possible

C. High priority features are delivered first, and these features will receive more testing

D. System design is easier

In the following agile development method, (30) use the iterative method, call a short period of iteration (such as 30 days) a sprint, and implement the product according to the priority of the requirement.

(30) A. Extreme Programming (XP) 

B. Crystal method (Crystal)

C. Parallel quest method (Scrum)

 D. Adaptive Software Development (ASD)

If module A transmits information to module B through control parameters, it is determined which part of the statement in module B is executed. Then the coupling type of these two modules is (31) coupling.

(31) A. Data B. Mark       C. Control        D. Public

Rules for implementing design for portability in design do not include (32).

(32) A. Separate design of device-related programs and device-independent programs

B. Dedicated features for specific environments are available

C. Use a platform-independent programming language

D. Do not use class libraries that depend on a certain platform

Which of the following statements about the advantages of the pipe-filter software architectural style is incorrect is (33).

(33) A. Components have good characteristics of high cohesion and low coupling

B. Support software reuse

C. Support parallel execution

D. Suitable for interactive processing applications

In the flow chart below, at least (34) test cases are required to cover all paths. The program complexity is calculated by McCabe method as (35).

(34) A. 3       B. 4        C. 5        D. 6

(35) A. 2      B. 3         C. 4        D. 5

After the software system is delivered to the user, in order to make the user interface more friendly and improve the graphical output of the system, this behavior belongs to (36) coupling maintenance.

(36) A. Corrective B. Adaptive       C. Improved       D. Preventive

The student performance management system is developed using object-oriented methods, and the student's name, gender, date of birth, final exam results, and operations to check grades are all (37) in the student object. Different classes are defined in the system, and objects of different classes communicate through (38).

(37)  A. Encapsulation      B. Inheritance C. Polymorphism D. Information

(38) A. Inheritance B. Polymorphism        C. Message       D. Overloading

When testing a system developed with object-oriented methods, it is usually tested from different levels. Every method defined in a test class belongs to a (39) layer.

(39)  A. Algorithm       B. Class        C. Template       D. System

In object-oriented system design, if a class in a package is reused, then all classes in the package must be reused, which belongs to the principle of (40).

(40) A. Common closure       B. Common reuse       C. Open-close D. Interface separation

The following description about the UML sequence diagram is (41), and the possible execution order of messages in the UML diagram shown in the figure below is (42).

(41) A. Externally visible services provided by the system in the context of its surrounding environment

B. A set of objects at a time and the relationships between them

C. Flow from one activity to another within the system

D. Interactions between objects organized in time order

(42) A. a→b→c→a→b 

B. c

C. a→b→a→b→c 

D. a→b→c→a→b→c

The UML package diagram shows the organizational units decomposed by the model itself and their dependencies. In the following statement about the package diagram, the incorrect one is (43).

(43) A. Can have classes, interface components, nodes 

B. An element can be owned by multiple packages

C. A package can nest other packages

 D. Elements in a package cannot have the same name

In a recruitment system, it is required to realize the function of automatically generating job resumes. The basic content of a resume includes the job seeker's name, gender, age and work experience. Expect the work history to be different on each resume and minimize duplication of code in the program. For this requirement, design the class diagram shown below. The design adopts the (44) pattern, the xx example specifies the type of object to be created, declares an interface for copying itself, and creates new objects by copying these Resume xx WorkExperience objects. This pattern belongs to the (45) pattern.

(44) A. Singleton

 B. Abstract Factory (Abstract Factory)

C. Builder 

D. Prototype

(45) A. Hybrid B. Behavioral C. Structural         D. Creational

A travel company wants to develop a software system, which requires that it can launch different travel pricing packages according to seasons, holidays, etc., such as off-season discounts, one-stop prices, etc. Achieving this requirement fits the pattern of (46) whose main intent is (47).

(46)  A. Strategy mode (Strategy) 

B. State (State)

C. Observer (Observer)

 D. Command (Command)

(47) A. Encapsulate a request as an object, so that the client can be parameterized with different requests

B. When the state of an object changes, the objects that depend on it are notified and automatically updated

C. Allows an object to change its behavior when its internal state changes

D. Define a series of algorithms, encapsulate them one by one, and make them interchangeable

Python uses the original method of (48) to get the type of an object.

(48) A. str()      B. type()       C. id()       D. object()

In the Python language, the statement x = (49) cannot define a tuple.

(49) A. (1, 2, 1, 2)     B. 1, 2, 1, 2        C. tuple()         D. (1)

In the statement about the Python language, (50) is incorrect.

(50) A. The for statement can be used on sequences (such as lists, tuples and strings) for iterative access

B. Else statements can be added after loop structures such as for and while

C. The selection structure can be represented by if...else and switch...case statements

D. Support nested loops

In the development process of the database application system, developers need to shield the complexity of the system from the user through abstraction at the view layer and logic level, and simplify the interaction process between the user and the system. The error is (51) .

(51) A. The view layer is the highest level of abstraction

B. The logic layer is a lower level of abstraction than the view layer

C. The physical layer is the lowest level of abstraction

D. The physical layer is a higher level of abstraction than the logical layer

Given a relational schema R(U, F), where U is a set of attributes and F is a set of functions on U, what belongs to the reflexive law is (52).

(52)  A. If Y∈X∈U, then X→Y is implied by F

B. If X→Y, Y→Z, then X→Y is implied by F

C. If X→Y, Z∈Y, then X→Z is implied by F

D. If X→Y, X→Z, then X→YZ is implied by F

Given a relational schema R(U, F), U = { A, B, C, D }, and a set of functional dependencies F = { AB→C, CD→B }. Relational schema R (53), the number of main attributes and non-main attributes are (54) respectively.

(53) A. There is only 1 candidate keyword ACB 

B. There is only one candidate keyword BCD

C. There are 2 candidate keywords ABD and ACD 

D. There are 2 candidate keywords ACB and BCD

(54)  A. 4 and 0  B. 3 and 1 C. 2 and 2 D. 1 and 3

If the insert permission of the Students table is given to user User1, and it is allowed to grant this permission to others, then the correct SQL statement is as follows: GRANT (55) TABLE Students TO User1 (56).

(55) A. INSERT      B. INSERT ON        C. UPDATE         D. UPDATE ON

(56) A. FOR ALL           B. PUBLIC       

C. WITH GRANT OPTION          D. WITH CHECK OPTION

When using the stack to evaluate the arithmetic expression 10 * (40 – 30 / 5) + 20, the capacity of the stack (initially empty) storing the operands is at least (57) to meet the temporary storage of the operands in the expression Or operation result requirements.

(57) A. 2     B. 3      C. 4        D. 5

There are 5 characters, and Huffman codes are constructed for them according to their frequency of use. (58) is not possible in the following encoding schemes.

(58) A. { 111, 110, 101, 100, 0 } 

B. { 0000, 0001, 001, 01, 1 }

C. { 11, 10, 01, 001, 000 } 

D. { 11, 10, 011, 010, 000 }

Assuming that the directed graph G has n vertices and e arcs and is stored in an adjacency list, the time complexity of breadth-first traversal is (59) .

(59)  A. O(n + e)

 B. O(n^2) 

C. O(e^2)

 D. O(n * e)

When performing a binary search (binary search) on an ordered list, the sequence of keywords to be compared cannot be (60).

(60) A. 42, 61, 90, 85, 77 

B. 42, 90, 85, 61, 77

C. 90, 85, 61, 77, 42

 D. 90, 85, 77, 61, 42

Assume that in a forest composed of three trees, the total number of nodes in the first tree, the second tree and the third tree are n1, n2 and n3 respectively. Convert the forest to a binary tree, then the right subtree of the binary tree contains (61) nodes.

(61) A. n1 B. n1 + n2 C. n3           D. n2 + n3

To sort a set of data, the time complexity of the sorting algorithm is required to be O(nlgn), and the sorting is required to be stable, then (62) can be used. algorithm. If the time complexity of the sorting algorithm is required to be O(nlgn), and it is performed on the original data, that is, the space complexity is O(1), then (63) can be used. algorithm.

(62) A. Direct insertion sort 

B. Heap sort

c. Quick sort 

D. Merge sort

(63) A. Direct insertion sort 

B. Heap sort

c. Quick sort 

D. Merge sort

The Kruskal algorithm is used to solve the minimum spanning tree in the figure below, and the algorithm design strategy adopted is (64). The weight of the minimum spanning tree is (65).

(64) A. Divide and conquer 

B. Dynamic programming

 C. Greedy method 

D. Backtracking

(65) A. 14      B. 16       C. 20       D. 32

The control protocol for www is (66).

(66) A. FTP      B. HTTP       C. SSL        D. DNS

(67) is commonly used in Linux operating systems. As a web server, its default web directory is (68) .

(67) A. IIS B. Apache 

C. NFS 

D. MYSQL

(68) A. /etc/httpd

 B. /var/log/httpd 

C. /etc/home 

D. /home/httpd

The transport layer protocol for SNMP is (69).

(69) A. UDP

 B. TCP 

C. IP 

D. ICM

A certain computer cannot open any webpage, but the Internet instant chat software works normally. The failure may be caused by (70).

(70) A. IP address configuration error

 B. DNS configuration error

 C. Network card failure 

D. Link failure

Low-code and no code software development solutions have emerged as viable and convenient alternatives to the traditional development process.

Low-code is a rapid application development (RAD) approach that enables automated code generation through (71) building blocks like drag-and-drop and pull-down menu interfaces. This (72) allows low-code users to focus on the differentiator rather than the common denominator of programming. Low-code is a balanced middle ground between manual coding and no-code as its users can still add code over auto-generated code.

No-code is also a RAD approach and is often treated as a subset of the modular plug-and-play, low-code development approach. While in low-code there is some handholding done by developers in the form of scripting or manual coding, no-code has a completely (73) approach, with 100% dependence on visual tools.

A low-code application platform (LCAP) — also called a low-code development platform (LCDP) — contains an integrated development environment (IDE) with (74) features like APIs, code templates, reusable plug-in modules and graphical connectors to automate a significant percentage of the application development process. LCAPs are typically available as cloud-based Platform-as-a-Service (PaaS) solutions.

A low-code platform works on the principle of lowering complexity by using visual tools and techniques like process modeling, where users employ visual tools to define workflows, business rules, user interfaces and the like. Behind the scenes, the complete workflow is automatically converted into code. LCAPs are used predominantly by professional developers to automate the generic aspects of coding to redirect effort on the last mile of (75).

(71) A. visual B. component-based C. object-oriented D. structural

(72) A. block B. automation C. function D. method

(73) A. medern  B. hands-off  C. generic D. labor-free

(74) A. reusable B. built-in C. existed D. well-konwn

(75) A. delivery B. automation C. development D. success

National Computer Technology and Software Professional Technical Qualification (Level) Examination

In the first half of 2023, software designer, afternoon test paper

(150 minutes in total from 14:00 to 16:30)

Please fill in the answer sheet correctly according to the following requirements

1. Fill in the name of your province, autonomous region, municipality directly under the central government, or city under separate state planning in the designated place on the answer sheet.

2. Fill in the test admission ticket number, date of birth and name in the designated place on the answer sheet.

3. In addition to filling in the above content, only answers can be written on the answer sheet.

4. There are 6 questions in this test paper. Questions 1 to 4 are mandatory questions, and questions 5 to 6 are optional. Each question is worth 15 points, and the full score is 75 points.

5. The handwriting must be clear when answering. If the handwriting is unclear, no marks will be given.

6. Follow the sample question below and write the answer in the corresponding column on the answer sheet.

(example)

The date of the national computer technology and software professional technical qualification (level) examination in the first half of 2023 is (January) (2).

Since the correct answer is "May 27", write "5" and "27" in the corresponding columns on the answer sheet (see table below).

example

answer column

(1)

5

(2)

27

Question 1 (15 points in total)

Read the following instructions and pictures, answer questions 1 to 4, and fill in the answers in the corresponding boxes on the answer sheet.

【illustrate】

With the development of scientific planting in the agricultural field, it is necessary to carry out information management on agricultural bases and farming, and provide planting-related services for tenants and farmers. Now we want to develop a farming management service platform. Its main functions are:

(1) Personnel management, platform administrators manage tenants; tenants manage farmers and allocate responsible land for them, tenants and farmers are distinguished by personnel type

(2) Base management, tenants fill in the base name, region and other descriptive information. Draw the plot on the displayed map

(3) Planting management. The tenant sets the crops and the entire farming process from planting to harvesting, including farming activities and their implementation plans. Farmers carry out farming activities and record them according to the corresponding farming process reminders. The system will remind farmers about farming at the set time, and issue overdue warnings to tenants for overdue activities

(4) Input management. Tenants uniformly maintain input information such as fertilizers and pesticides, and farmers set the actual consumption of inputs in farming activities

(5) Information service: The user initiates a request for agricultural information according to the query conditions, and performs selection, comparison, and statistical processing of agricultural information such as the implementation of agricultural activities in relevant plots (such as comparison with the agricultural process), and displays the response information .The system also provides APP interfaces for other third-party software. Through the interface access, provide account numbers, passwords and query conditions to initiate agricultural information requests, and return agricultural information in a specific format. When there are no query conditions, it will silently return all information under the account. Multi-query When the conditions are met, return information that meets all conditions

Now use the structural method to analyze and design the agricultural management service platform, and obtain the context data flow diagram shown in the figure and the 0-layer data flow diagram shown in Figure 1-2.

【Question 1】(4 points)

Using the words in the description, give the names of the entities E1-E4 in Figure 1-1

【Question 2】(4 points)

Using the words in the description, give the names of the datastores D1-D4 in Figure 1-2

【Question 3】(4 points)

Missing data streams and their starting and ending points in Supplementary 1-2 according to description and figure terminology.

【Question 4】(3 points)

According to the description, give the composition of the "agricultural information request" data flow.

Question 2 (total 15 points)

Read the following instructions, answer questions 1 to 4, and fill in the answers in the corresponding columns on the answer sheet.

【illustrate】

A new energy vehicle company in order to improve efficiency. Need to develop an auto parts procurement system. Please complete the database design of the system. 【Concept structure design】

(1) Record the supplier's information, including the supplier's name, address and a telephone number.

(2) Record the information of the parts, including the code, name and price of the parts.

(3) Record the model information, including the serial number, name and specification of the model.

(4) Record parts procurement information. A certain part of a certain model can be purchased from multiple suppliers, a certain part can also be used by multiple models, and a certain supplier can also supply multiple parts, including the purchase quantity and date of purchase.

【Logical Structure Design】

According to the entity relationship diagram completed in the conceptual structure design stage, the following relationship model (incomplete) is obtained:

Supplier (name, address, phone)

Parts (code, each name, price)

Models (numbers, names, specifications)

purchase(model number, supplier name, (a), (b), date of purchase)

【Question 1】(5 points)

According to the description, supplement the entity connection diagram of Figure 2-1 (no new entities are added)

【Question 2】(3 points)

Supplement the two vacancies (a) and (b) in the structural design results, and mark the integrity constraints of primary key and foreign key.

【Question 3】(7 points)

The car company now adds the following requirements: record the sales of models in stores across the country, store information includes store number, address and phone number, sales include sales quantity and sales date, etc.

The following modifications are made to the original design to meet this requirement:

(1) In Figure 2-1, reflect the store information and its model sales, and indicate the newly added entity and connection, and its main attributes.

(2) Give the newly added relationship schema, and mark the integrity constraints of the primary key and foreign key

Question 3 (15 points in total)

A university library has purchased a number of mirror database (MinorDBMino) resources of academic resources, and now requires the development of a digital library (Digital library) system to provide academic resources (Resoure) browsing, retrieval and download service system for users on campus The main requirements are described as follows:

(1) The system stores the basic information of each mirror database, including: database name, access address, database attributes, database profile and other information. After entering a certain mirror database, users can browse, retrieve and download the academic resources in it.

(2) Academic resources include conference papers (ConferencePaper), sentence papers (JounalArticle), and degree (Thesis), etc.: the system stores the title, author, publication time, source (which mirror database), cited times, download times, etc. For conference papers, the name, time and location of the conference should also be recorded; papers from the same conference are included in the Proceedings. For journal papers, it is also necessary to record the journal name, publication month, issue number and sponsor; papers with the same issue number are included in one journal (Edition). For dissertations, record the degree category (Ph.D./M.S.): graduate school, major and supervisor. A conference collection contains all the articles published at that conference (held at a specific location at a specific time period). Each issue of a journal is issued at a specific time and contains several articles.

(3) System users (User) include students (Student), teachers (Teacher) and other in-service personnel (Staff). After users use the school's unified identity authentication to log in to the system, they can use various services provided by the system.

(4) The system provides a variety of resource retrieval methods, mainly including: Search by Title of Resource (SearchbyTite), Search by Author Name (SearchByAathor), Search by Source (SearchBySource), etc.

(5) Users can download resources, and the system records the number of times each resource is downloaded. The system is now developed using the object-oriented analysis and design method, and the use case diagram shown in Figure 3-1 and the initial class diagram shown in Figure 3-2 are obtained.

【Question 1】(8 points)

According to the description in the description, give the class names of the corresponding items of C1-C8 in Figure 2.

【Question 2】(4 points)

According to the description in the description, give the key attributes of the classes C1-C4 in Figure 2

【Question 3】(3 points)

During the development of the system, new requirements were encountered; users can register other citation notifications for the digital resources they care about in the system, and if the number of other citations of the resources changes, the system can notify the user in time. With this new requirement, which design pattern can be added to the class diagram shown in Figure 3-2? Explain the reason for choosing this mode in 150 words or less.

Question 5 (15 points in total)

Read the following instructions and Java code, and write the words and sentences that should be filled in (n) in the corresponding column on the answer sheet.

【illustrate】

In a system, class interval represents an interval defined by a lower bound and an upper bound. Requires a different format to display interval ranges. Such as [lower bound, upper bound]; [lower bound...upper bound]; [lower bound-upper bound], etc. Now adopt the strategy mode to realize this requirement, and get the class diagram shown in Figure 5-1.

Figure 5-1 slightly

[Java code]

import Java.util.enum

TYPE{COMMA, Dots, LINE}

interface PrintStrategy{

public __(1)__;

(1):void doPrint(interval val)

}

class Intervals{

//Two class member variables = upper and lower boundary values

public void Intervals(double lower, double upper){

//Initialize upper and lower boundary values

}

public double getLower {return lower...}

public double getUpper {return upper...}

public void printInterval (PrintStrategy pr){

__(2)__;

}

}

class PrintIntervalsComma implements PrintStrategy{

public void doPrint (interval Val){

system.out.printin("["+val.getLower()+","+val.getUpper()+"]"}

}

class PrintIntervalsDots implements PrintStrategy{

public void do print (interval val){

system.out.printin("["+val(.getLower()+"..."+val.getUpper()+"]";}

}

class PrintIntervalsLine implements PrintStrategy{

public void do print (interval val){

system.out.print("["+val.getLower()+"-"+val.getUpper()+"]";}

}

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){

Intervals a = new Intervals(1.7, 2.1);

a.printInterval (getStrategy(TYPE.COMMA));

a.printInterval (getStrategy(TYPE.Dots));

a.printInterval (getStrategy(TYPE.LINE));

}

Answers to afternoon questions:

Guess you like

Origin blog.csdn.net/weixin_68261415/article/details/131047469