Bug 570

Summary: Incorrect method realization
Product: CS3343 Chinese Checker Reporter: yutongmen2-c
Component: Algorithm ComponentAssignee: yutongmen2-c
Status: RESOLVED FIXED    
Severity: normal CC: yutongmen2-c
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   

Description yutongmen2-c 2021-11-17 23:47:01 HKT
Problem: The method getInstance() is wrong in the class Graph is wrong.

Steps to reproduce: N/A

Actual outcome: N/A

Expected outcome: N/A
Comment 1 yutongmen2-c 2021-11-17 23:47:34 HKT
Wrong implementation:


public static Graph getInstance() {

         if (instance != null) {
         return instance;
         } else {
         return new Graph();
         }
        if (instance == null)
            instance = new Graph();
        return instance;
    }

Correct implementation:

public static Graph getInstance() {


        if (instance == null)
            instance = new Graph();
        return instance;
    }