Bug 554

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

Description yutongmen2-c 2021-11-11 14:24:17 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-12 19:08:10 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;
    }