需要类继承帮助,基类保存通用数据,继承类具有特定数据. [英] Help with class inheritance needed, base class holds generic data inherited class has specific data.

查看:80
本文介绍了需要类继承帮助,基类保存通用数据,继承类具有特定数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件都是带分隔符的文本,不超过128个字节.
有3种特定类型的文件,即操作员,乘车和点.
我知道我期望的文件类型,但是我可以可以使用任何类型运算符,骑乘和指向每个

文件的第一部分将包含标签类型,即"Ride%........%..........%";或运算符%........%.............%"

我读取文件,然后根据文件类型将其拆分为正确的部分

运算符
名称
编号


Ride
RideName
Ride Number
点数

Point
PointName
Point number
允许的时间.
最后检查日期

在基类中,我为所有类定义了所有字段,并使用_data.split('%' );
根据第一个数据部分的内容将数据分为正确的部分.

I have files which are all delimited text of no more than 128 bytes.
There are 3 specific types of file, operator, ride and point.
I know what type of file I am expecting but I can be given any type.

I may have gone about this the completly wrong way and please feel free to tell me if I have.

I have a base class of Tag and 3 inherited classes of operator, ride and point each

The first part of the file will contain the tag type ie "Ride%........%..........%" or "Operator%........%..........%"

I  read the file and then split it into the correct parts depending on what type of file it is.

Operator
    Name
    Number


Ride
    RideName
    Ride Number
    Number of points

Point
    PointName
    Point number
    Time allowed.
    Last check date

In the base class I have defined all the fields for all classes and use  _data.split('%');
to break the data into the correct parts depending on what the first data part is.

<身体>
公共 标签
{
//字段
受保护的 字符串 _ data;
受保护的 字符串 _ tagType;
受保护的 字符串 _ rideName;
受保护的 字符串 _ rideNumber;
受保护的 字符串 _ noOfPoints;
受保护的 字符串 _ pointName;
受保护的 字符串 _ pointNumber;
受保护的 字符串 _ timeAllowed;
受保护的 字符串 _ operatorName;
受保护的 字符串 _ operatorNumber;
public class Tag  
 
{  
 
 
// Fields  
 
protected string _data;  
 
protected string _tagType;  
 
protected string _rideName;  
 
protected string _rideNumber;  
 
protected string _noOfPoints;  
 
protected string _pointName;  
 
protected string _pointNumber;  
 
protected string _timeAllowed;  
 
protected string _operatorName;  
 
protected string _operatorNumber;  
 
 

推荐答案

是一项家庭作业,因此在提供任何帮助之前,我想确保在答复时您不会被欺骗.在过去的几年中,我已经看到很多这样的案例.

Driss.
This reads like it is a homework assignment, so before offering any assistance, I'd like to make sure that in responding you will not be nailed for cheating. I've seen plenty of cases of this over the past couple of years.

Driss.


这篇关于需要类继承帮助,基类保存通用数据,继承类具有特定数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆