联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Algorithm 算法作业Algorithm 算法作业

日期:2024-10-05 06:38

CSE1OOF/CSE4OOF Programming Assessment

Create an object-oriented design from a problem description, and implement as a working Java program

Assigned to students 2 September 2024

Due Sunday 6 October @ 11:55pm (end of Week 9)

Worth 20% of your final marks

Late penalty 5% per day

You will, using object-oriented principles, design a set of interrelated classes and implement them as a Java program. Do you have the time?

Specifically, you will create and document a program for converting, storing, and modifying date and time values in a variety of different formats.

Part I: Date, Time, and DateWithTime (10 marks)

You will implement three classes Date, Time, and DateWithTime. A date consists of a day, a month, and a year; a time consists of hours, minutes, and seconds. Create these three classes with the appropriate variables. For now, just implement one constructor and accessor/mutator methods as needed.

Part II: Instantiate classes with keyboard input (30 marks)

You will implement a class, DateTimeTester, that can be run (that is, has a main function) and is able to instantiate Date, Time, and DateWithTime objects (that is, they are in the same package).

You will also implement the .toString() method in each of the original classes so that it prints out the date, time, or date+time in a reasonable format.

Implement the main function such that you can create a Date, a Time, and a DateWithTime with keyboard input. You should be able to choose which type of object you are creating.

Part III: Write functions to instantiate objects with random values (30 marks)

You will implement a single-parameter constructor for each of Date, Time, and DateWithTime that takes a single boolean value. If that value is false, the object will be initialized with reasonable default values. If that value is true, the object will be initialized with random values in the appropriate ranges.

You will then modify DateTimeTester to enable the user to create random Dates, Times, and DateWithTimes.

Part IV: Make your Dates and Times as flexible as possible (30 marks)

There are many possible date formats: DD/MM/YYYY (i.e. 02/09/2024), DD/MM/YY (02/09/24), MM/DD/YYYY (09/02/2024), MM/DD/YY (09/02/24), 02 September 2024, 02 SEP 2024, September 02 2024, Sep 2 2024, and more besides. Dates are complicated, as we all know.

You will implement a single-parameter constructor for Date that takes a string and, assuming it is in a “reasonable” format, successfully creates the appropriate date. (Note that you might not always be correct; DD/MM/YYYY and MM/DD/YYYY are sometimes interchangeable – as with 02 September (2/9 or 9/2 are both valid values) – and sometimes not – as with 20 September (20/9 can only mean 20 September, it cannot mean the 9th of the 20th. Make reasonable assumptions and document them in the comments.)

Rubric

Part I: Date, Time, and DateWithTime (10 marks)

- Classes are named appropriately 1 marks

- Classes have at least one constructor 1 marks each

- Classes have the necessary variables 1 marks each

- Classes have the appropriate getters and setters 1 marks each

Part II: Instantiate classes with keyboard input (30 marks)

- DateTimeTester exists 1 mark

o DateTimeTester contains a valid main method 2 marks

- Time.toString() exists 1 mark

o Time.toString prints out a time in the 24-hour format hh:mm:ss 2 marks

- Date.toString() exists 1 mark

o Date.toString prints out a date in the format dd Month yyyy 2 marks

- DateWithTime.toString() exists 1 mark

o DateWithTime prints out a date + time in the format dd Month yyyy hh:mm:ss 2 marks

- Date, Time, DateWithTime, and DateTimeTester are in the same package 2 marks

- DateTimeTester displays a “menu” that enables the user to choose which type of object they want to create 4 marks

- This top menu works appropriately 4 marks

- DateTimeTester then asks the user for keyboard input to create the appropriate class 4 marks

- DateTimeTester then prints out the created class object, or an error as appropriate 4 marks

Part III: Write functions to instantiate objects with random values (30 marks)

- Date(boolean) exists 2 marks

- Time(boolean) exists 2 marks

- DateWithTime(boolean) exists 2 marks

- Default Date construction yields a Date with a reasonable value 4 marks

- Default Time construction yields a Time with a reasonable value 4 marks

- Default DateWithTime yields a DateWithTime with a reasonable value 4 marks

- Random Date construction yields a Date with a reasonable value 4 marks

- Random Time construction yields a Time with a reasonable value 4 marks

- Random DateWithTime yields a DateWithTime with a reasonable value 4 marks

Part IV: Make your classes as flexible as possible (30 marks)

- Time(String) exists 1 mark

- Date(String) exists 1 mark

- DateWithTime(String) exists 1 mark

- Handle Times in the 12 hour + am/pm format (i.e., 4:29 am) 3 marks

o Handle such times with and without a space before am/pm 1 mark

o Handle such times with capitalized or lowercase am/pm 1 mark

- Handle Times in the 24 hour format (i.e., 0429) 3 marks

- Handle Dates in the dd/mm/yyyy format (i.e. 03/09/2024) 3 marks

- Handle Dates in the dd MMM yyyy format (i.e. 3 SEP 2024) 3 marks

- Handle Dates in the dd Month yyyy format (i.e. 3 September 2024) 3 marks

- Handle DateWithTimes in any combination of the preceding formats (i.e. 3 September 2024 4:29AM, 03/09/2024 0429, and so on…) 10 marks


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp