制作这个Java程序的最好方法是什么? [英] What's the best way to make this Java program?

查看:129
本文介绍了制作这个Java程序的最好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是程序简介的描述:


制作一个软件,跟踪讲师在大学讲授的课程。对于每个课程,需要记录课程代码和标题,以及需要记录课程的讲师名单。该系统应该允许添加和删除课程和讲师从列表和信息,如讲师课程和课程注册到特定的讲师要显示。

Produce a software that keeps track of courses taught by lecturers at College. For each course, a course code and title needs to be recorded, as well as a list of lecturers taking that course needs to be recorded. The system should allow courses and lecturers to be added and removed from the list and information such as lecturers taking a course and courses registered to a particular lecturer to be displayed.






到目前为止,我有两个类讲师和课程和他们两个属性,如名称id,代码和标题。我已经创建了两个类来保存这两个对象的数据,我已经使用了一个Map,所以我已经映射了ID和名称为Lecturer,代码和标题的课程,他们都在独立的类,称为LecturerList和CourseList。


So far I have two classes Lecturer and Course and they two attributes such as name id, and code and title respectively. I have then created two more classes to hold the data for both of those objects and I have used a Map, so I have mapped id and name for Lecturer and code and title for course, they are both in seperate classes called LecturerList and CourseList.

但现在我不能将课程分配给讲师。已经坚持在这一个星期了。有任何想法吗?我接近这个错误的方式吗?

But now I can't allocate a course to a lecturer. have been stuck on this for a week now. Any ideas? Have I approached this the wrong way?

推荐答案

我不同意这个问题需要一个数据库。它是面向对象的部分,你有问题。如果你需要持久化,就会得到正确的数据库。

I disagree that the problem needs a database. It's the object-oriented part that you're having problems with. Get that right and a database will follow if you need persistence.

我从课程和讲师开始,就像你一样。课程将具有所需的代码和标题属性,以及一个教学员名单。同样,讲师将有一个名称属性和一个课程列表被教。这听起来像一个双向的1:m的关系。你的问题陈述的语言有点混乱,但它听起来像一个课程可以教几个讲师(可能是因为有一个给定的课程的几个部分),一个讲师可以教多于一个课程。

I'd start with Course and Lecturer, as you did. Course would have the required code and title attributes, plus a List of Lecturers teaching it. Likewise, Lecturer would have a name attribute and a List of Courses being taught. It sounds like a bi-directional 1:m relationship to me. The language of your problem statement is a bit confusing, but it sounds like a Course can be taught by several Lecturers (perhaps because there are several sections of a given Course), and a Lecturer can teach more than one Course.

如果这听起来很准确,我不认为你需要一个CourseList或LecturerList类。

If this sounds accurate, I don't think you need a CourseList or LecturerList class.

这篇关于制作这个Java程序的最好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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