Java Android 多类图

发布于 2024-11-30 10:11:31 字数 399 浏览 1 评论 0原文

我想编写一个用于锻炼的应用程序,并且需要一些有关类图的建议。我希望用户能够在健身房使用该应用程序。用户将开始锻炼,进行任意数量的练习,每个练习有任意组数。

我的想法是这样的:

-每次锻炼都有一个日期和时间。即使用户每天锻炼超过一次,这也使它们能够保持独特。

- 每个练习都有一个名称。

- 每组都有重量和重复次数。

示例:

20xx-XX-XX XX:XX(锻炼) 深蹲(练习) 100x5(套) 100x5(套) 100x5(套) 卧推(练习) 50x8(套) 50x8(套) 50x8(设置)

那么,将所有这些组合在一起的最佳方法是什么?我想也许每个锻炼都可以有一个地图,其中练习作为键,数组列表包含集合作为值。这是一个好的解决方案吗?或者有更好的解决方案吗?

I want to write an app for workouts and I need to some advice for the class diagram. I want the user to be able to use the app at the gym. The user will start a workout, do an arbitrary number of exercises, each with an arbitrary number of sets.

The way I thought of it is like this:

-Each workout has a date and a time. This enables them to be unique even if the user works out more than once a day.

-Each exercise has a name.

-Each set has a weight and a rep count.

Example:

20xx-XX-XX XX:XX (workout)
Squats (exercise)
100x5 (set)
100x5 (set)
100x5 (set)
Bench press (exercise)
50x8 (set)
50x8 (set)
50x8 (set)

So, what is the best way to put all this together? I thought maybe each workout could have a map with exercises as keys and arraylists containing sets as values. Is this a good solution? Or are there better solutions?

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

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

发布评论

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

评论(1

还给你自由 2024-12-07 10:11:31
class User 
{
   List<Workout> _workouts;
}

class Workout
{
    Date _startdate;
    Date _enddate;
    Map<Exercise,List<Set>> _exercises;
}

class Exercise
{
    String _name;
}        

abstract class Set
{
    abstract int getTotal();
}

class WeightSet extends Set
{
    int _weight;
    int _reps;

    @override
    public String toString() {return _weight + "X" + _reps;}
}

class CardioSet extends Set
{
    int _durationInSeconds; 
    int _distance;
}
class User 
{
   List<Workout> _workouts;
}

class Workout
{
    Date _startdate;
    Date _enddate;
    Map<Exercise,List<Set>> _exercises;
}

class Exercise
{
    String _name;
}        

abstract class Set
{
    abstract int getTotal();
}

class WeightSet extends Set
{
    int _weight;
    int _reps;

    @override
    public String toString() {return _weight + "X" + _reps;}
}

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