using System.Collections.Generic; using UnityEngine; namespace ZXL.Excel { [System.Serializable] public class SingleChoice_QuestionBank_B_Data { private readonly QuestionType questionType = QuestionType.单选题; private List _list; public List data => _list; public SingleChoice_QuestionBank_B_Data(List list) { _list = list; foreach (var infos in _list) { List strings = new List(); for (int i = 0; i < infos.options.Length; i++) { var infosOption = infos.options[i].Trim(); strings.Add(infosOption); } infos.options = strings.ToArray(); } } public void Remove(string id) { for (var i = 0; i < _list.Count; i++) { if (_list[i].id == id) _list.Remove(_list[i]); } } public SingleChoice_QuestionBank_B_DataInfo RandomGet() { SingleChoice_QuestionBank_B_DataInfo info = null; if (_list.Count <= 0) { return null; } var range = Random.Range(0, _list.Count); info = _list[range]; _list.RemoveAt(range); return info; } } [System.Serializable] public class SingleChoice_QuestionBank_B_DataInfo { public string id; public string topic; public string[] options; public string[] answer; public SingleChoice_QuestionBank_B_DataInfo(string id, string topic, string[] options, string[] answer) { this.id = id; this.topic = topic; this.options = options; this.answer = answer; } } }