JJBB/Assets/Project/Script/GameTables/Table_QuestionBank.cs
2024-08-23 15:49:34 +08:00

74 lines
1.7 KiB
C#

//This code create by CodeEngine ,don't modify
using System;
using System.Collections.Generic;
using System.Collections;
using Module.Log;
namespace GCGame.Table
{
public class Tab_QuestionBank{
public const string TAB_FILE_DATA = "QuestionBank";
private const int _varCount = 9;
public int GetId()
{
return Id;
}
public static bool Validate(string line)
{
var segments = 0;
foreach (char c in line)
if (c == '\t')
segments++;
// Note: skip the 2nd column as it's the description;
var result = segments == _varCount;
if (!result)
LogModule.ErrorLog(string.Format("Load {0} error as CodeSize:{1} not Equal DataSize:{2}", TAB_FILE_DATA, _varCount, segments));
return result;
}
public Tab_QuestionBank()
{
}
public Tab_QuestionBank(string line)
{
var segments = line.Split('\t');
Id = int.Parse(segments[0]);
QuestionType = int.Parse(segments[2]);
QuestionDesc = segments[3].Trim();
Answer[0] = segments[4].Trim();
Answer[1] = segments[5].Trim();
Answer[2] = segments[6].Trim();
Answer[3] = segments[7].Trim();
RightAnswer = segments[8].Trim();
Time = int.Parse(segments[9]);
}
public int Id { get; private set; }
public int QuestionType { get; private set; }
public string QuestionDesc { get; private set; }
public readonly string[] Answer = new string[4];
public int getAnswerCount() { return Answer.Length; }
public string GetAnswerbyIndex(int idx)
{
if(idx >= 0 && idx < Answer.Length)
return Answer[idx];
return default(string);
}
public string RightAnswer { get; private set; }
public int Time { get; private set; }
}
}