关于OOP和对象的问题

发布于 2024-09-03 14:19:47 字数 283 浏览 7 评论 0原文

我有一个学校作业:狗展。

我的任务是创建一个网站,访客可以在其中显示结果,法官和秘书可以在其中进行管理和 CRUD。

我有一个小问题,作业的一部分:结果应该基于不同法官的两个决定,然后由秘书检查,然后再将结果显示给用户。

我不得不说我对编程相当陌生,所以我需要一些关于如何设计和实现它的明智建议。作业应涵盖 DB 和 C# (.NET MVC)。

Q1:如何创建一个依赖于另外两个对象(法官的决定)的对象(结果)?还需要这个吗?

Q2:如何在关系数据库中解决这个问题?

I have a school assignment: a Dog Show.

My assignment is to create a website, where vistors can display results, and where Judges and Secretary can admin and CRUD.

I have a small problem, one part of the assignment: the result should be based on two decisions from different judges, and after that checked by the secretary, before the result is displayed for the user.

I have to say I'm fairly new to programming, and so I need some smart suggestions on how to design and implement this. The assignment should cover both a DB and C# (.NET MVC).

Q1: How do i create a object (result) that depends on two other objects (judge's decisions)? Is that even needed?

Q2: How to solve this in a relational db?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事灯 2024-09-10 14:19:51

我认为使用关系数据库解决这个问题并不困难。我建议您将数据库中的每个表视为代表对象模型中的一个实体(类)。您可能需要考虑的一些实体包括狗展、狗、参赛、判决、结果、法官、秘书(法官/秘书可能都是官员)。根据您的定义,每个条目将有 2 个判断(因此您应该有一对多关系),但每个条目只有 1 个结果。您可以使用代码或数据库约束(或两者)来确保在该条目有两个判断之前不会创建该条目的结果。同样,您可以使用代码/约束来确保为每个条目输入的判断不超过两个。

希望这有助于您入门。

I don't think this would be hard to solve using a relational DB. I'd suggest that you consider each table in the database as representing an entity (class) in your object model. Some entities that you might want to consider Dog Show, Dog, Entry, Judgement, Result, Judge, Secretary (Judge/Secretary might both be an Official). According to your definition, each Entry would have 2 Judgements (thus you should have a 1-to-Many relationship there), but each Entry only has 1 Result. You might use code or a database constraint (or both) to ensure that a Result for an Entry isn't created until there are two Judgements for that Entry. Likewise, you might use code/constraint to ensure that no more than two Judgements are entered for each Entry.

Hope this helps get you started.

吖咩 2024-09-10 14:19:51

如何创建一个依赖于其他两个对象(法官的决定)的对象(结果)?还需要这个吗?

我建议您在创建第二个决策对象时创建结果对象。

伪代码可能类似于,当法官尝试创建新决策时,然后查看已经存在多少其他决策:

  • case 0:这是第一个决策;只需创建新决策并返回

  • 情况 1:这将是第二个决策;创建新的决策,然后根据两个决策创建结果

  • 情况 2 或更多:两个决策已存在,因此不允许创建进一步的决策。

另一种(也许不太好)的可能性是有一个单独的“创建结果”过程,该过程连续运行(不是连续的:例如,每分钟一次),寻找任何已创建的没有相应结果的决策对,并且创建相应的结果。

How do i create a object (result) that depends on two other objects (judge's decisions)? Is that even needed?

I suggest that you create the result object, when you create the 2nd decision object.

The pseudocode might be something like, when the judge tries to create a new decision, then see how many other decisions already exist:

  • case 0: this is the first decision; just create the new decision and return

  • case 1: this will be the second decision; create the new decision, and then create the result based on the two decisions

  • case 2 or more: two decisions already exist, so don't allow this further decision to be created.

Another (perhaps not so good) possibility is to have a separate "create results" process, which runs continually (not continuously: e.g., once every minute), looking for any already-created decision-pairs for which there's no corresponding result, and creating the corresponding result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文