Bug 554 - Incorrect method realization
Summary: Incorrect method realization
Status: CONFIRMED
Alias: None
Product: Chinese Checker
Classification: Unclassified
Component: Algorithm Component (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Assignee: yutongmen2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-11 14:24 HKT by yutongmen2-c
Modified: 2021-11-12 19:08 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;
    }