[help]借助图表创建c ++类 [英] [help] create c++ class with the help of diagram

查看:91
本文介绍了[help]借助图表创建c ++类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们请帮我完成这个任务........我需要在下面显示的对象图的帮助下创建c ++类



任务



您需要在C ++中为以下类图提供实际的实现。你必须以C ++的类形式提供解决方案。



图表链接

https://skydrive.live.com/redir?resid=8B2D8A874799F882!158&authkey=!AGWdCBkmuXTfLLA [ ^ ]



详细说明

您需要提供以下类的C ++实现:



1. PropertyCategories

2.情节

3.平面

4.房子



以下是各类的所有数据成员和成员函数的描述:


$ b $bPropertourCategories的数据成员:



o社区名称:此数据成员将用于了解公寓,房屋或地块所属的社会/城镇名称。

o面积:地块,公寓或房屋所覆盖的总面积。面积将是平方英尺或Marla单位。




$ b $bPropertyCategories方法:

o构造函数(s )和析构函数。

o Area andSocietyNamedata成员的Setter和getter函数。


$ b $b剧情数据成员:

o PlotNo:与绘图相关联的数字将显示给用户。


$ b $b绘图方法:

o构造函数和析构函数。

o PlotNodata成员的Setter和getter函数。

o isPlotAllotted()将确保是否已经分配了地块。如果情节尚未分配给任何人,则将其分配给当前用户并进行分配。

o isCornerPlot()将检查当前情节是否为角点图。在这方面你可以从用户那里获得输入。

o isDeveloped()这将确保情节是否处于发达状态。如果可以使用电力,天然气,道路等设施,则可以考虑开发地块,否则将考虑未开发的地块。


$ b $b数据成员平面

o FlatNo:与公寓相关的数字将显示给用户。


$ b $b公寓方法

o构造函数和析构函数。

o FlatNodata成员的Setter和getter函数。

o isOccupied()将检查此单位是否可用于出租,出售目的与否。如果有人住在公寓里,那么我们就不能出租或出售这套公寓。


$ b $b众议院数据会员

o HouseNo:将向用户显示与房屋相关联的数字。


$ b $b房屋方法

o类的构造函数和析构函数。

o HouseNodata成员的Setter和getter函数。

o isOccupied()将检查这个房子是否可用于出租,出售目的与否。如果有人住在这所房子,那么我们就不能出租或出售这栋房子。



Plz朋友帮我紧急



注意 :我不需要它实施到程序中.....只是大学的一项任务




[基于OP评论由Jibesh编辑]

请你能告诉图中所示的类之间的继承关系吗?因为我知道如何创建类,成员唯一重要的是类之间的关系

解决方案

有趣的是,这甚至不是一个对象模型,它是一个类模型。



为图中的每个类创建一个类,添加成员对于属性和方法,创建反映图中那些的继承关系,请教导他为什么他给你一个无效的图表(假设它应该是UML)用于聚合:共享线渲染他们毫无意义。



1.房子是否有(共用?)参考单位和地块?

2.是否单位有参考情节吗?



我先问问图表。它不是有效的UML,所以除非你做出假设,否则实际上不可能正确回答作业。



(欢迎软件开发,有时(或通常)你在解决问题之前必须完善要求。)


我们不为人们做功课 - 不是因为我们觉得我们是精英或太重要,但是因为如果我们为你做这件事你就不会学到任何东西。如果你试图这样做并且对代码的特定部分有问题,那就回到这里并询问有关代码特定部分的问题 - 不是整个申请。如果你现在还没有学到这些基本/必备的技能,那么你可以先决定另一个职业道路,然后再将另一个 - 更好的 - 程序员放弃工作,因为你的工资要求较低。


来源 [ ^ ]


您在图像中共享的内容是''UML-Class Diagram'',以了解有关所用表示的更多信息。 a''Class Diagram''检查这个 [ ^ ]。他们详细解释了每个符号的例子。



正如我所说,我不打算与你分享源代码,而是我会解释你的类是如何相关的类图。



1.PropertyCategories是Plot,Flat和House的基础

2.Class Flat包含Plot实例(但不是父母)

3.Class House包含Plot的实例(但不是父母)



希望你现在对实现有所了解。



我建议你仔细阅读Class Diagram链接,以了解

Quote的含义:

(但不是父)

语句。



另外,Rob说这个类图是不完整的,它只是显示了类之间的关系,但不包含多少个实例。如果你要做的话,请仔细检查图表带有此图的真实程序


Hi friends plz help me with this task........ I need to create c++ classes with help of object diagram shown below

TASK:

You are required to provide a practical implementation in C++ for the following class diagram. You have to provide the solution in the form of classes in C++.

Diagram link
https://skydrive.live.com/redir?resid=8B2D8A874799F882!158&authkey=!AGWdCBkmuXTfLLA[^]

Detail Description
You are required to give C++ implementation of following classes:

1. PropertyCategories
2. Plot
3. Flat
4. House

Following is the description of all data member and member functions of respective classes:

 Data members for PropertyCategories:

o SocietyName: This data member will be used to know the society/town name from where flat, house or plot belongs to.
o Area: Total area covered by the plot, flat or house. Area will be in square feet or Marla unit.


 Methods for PropertyCategories:
o Constructor(s) and destructor.
o Setter and getter function for Area andSocietyNamedata members.

 Data members for Plot:
o PlotNo: A number associated with a plot will be shown to user.

 Methods for Plot:
o Constructor(s) and destructor.
o Setter and getter function for PlotNodata member.
o isPlotAllotted() will ensure whether plot is already allotted or not. If plot is not already allotted to anyone then assign it to current user and make it allotted.
o isCornerPlot () will check whether current plot is corner plot or not. You can take input from user in this regard.
o isDeveloped () this will ensure that whether plot is in developed status or not. A plot is consider to be developed if, facilities such as electricity, gas, road etc are available, otherwise it will be consider undeveloped plot.

 Data members for Flat
o FlatNo: A number associated with a flat will be shown to user.

 Methods for Flat
o Constructor(s) and destructor.
o Setter and getter function for FlatNodata member.
o isOccupied() will check whether this flat is available for rent, selling purpose or not. If anyone is staying in the flat then we can’t rent out or sell this flat.

 Data members for House
o HouseNo: A number associated with a house will be shown to user.

 Methods for House
o Constructor(s) and destructor for class.
o Setter and getter function for HouseNodata member.
o isOccupied() will check whether this house is available for rent, selling purpose or not. If anyone is staying in this house then we can’t rent out or sell this house.

Plz friends help me its urgent

NOTE: i don''t need it to implement into the program ..... Just a task from college


[Edited by Jibesh based on OPs comment]
Please can you tell the inheritance relationship between class shown in the diagram ..... Coz i know how to create classes, members the only thing that matters is the relationship between classes

解决方案

Funnily, that isn''t even an object model, it''s a class model.

Create a class for each class in the diagram, add members for the attributes and methods, create inheritance relationships reflecting those in the diagram, ask your tutor why he''s given you an invalid diagram (assuming its supposed to be UML) for the aggregations: the shared lines render them meaningless.

1. Does a house have (shared?) ref''s to a flat and a plot?
2. Does a flat have a ref to a plot?

I''d question the diagram first. Its not valid UML, so it''s actually impossible to correctly answer the assignment unless you make assumptions.

(Welcome to software development, sometimes (or normally) you have to refine the requirements before tackling a problem).


"We don''t do homework for people - not because we feel like we''re elite or too important, but because YOU won''t learn anything if we do it for you. If you try to do it and have a problem with a particular part of the code, come back here and ask a question about THAT particular part of the code - NOT the entire application. If you don''t learn these basic/essential skills now, you may as well decide on another career path before you put another - BETTER - programmer out of work simply because of your lower salary requirements."


Source[^]


What you shared in the image is a ''UML-Class Diagram'' to know more about the representations used in a ''Class Diagram'' check this[^]. they explained each notations with example in detail.

As I said I am not going to share you the source code rather I would explain how your classes are related based on the class diagram.

1.PropertyCategories is the base for Plot,Flat and House
2.Class Flat Contains instances of Plot (but not the parent)
3.Class House Contains instance of Plot (but not the parent)

Hope you get some idea about the implementation now.

I would recommend you to read the Class Diagram link carefully to know the meaning of

Quote:

(but not the parent)

statement.

Also as Rob said this Class diagram is incomplete it just shows relation between the classes but doesnt contains how many instances.so double check the diagram if you are going to do real program with this diagram


这篇关于[help]借助图表创建c ++类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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