Course Hero Logo

Q9 consider the following java class public class

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 4 - 5 out of 5 pages.

Q9.Consider the following Java class.public class Clock {private Integer startTime;private Integer numHours;public Clock( Integer start, Integer hrs ) {startTime = start;numHours = hrs;}}Modify this class and introduce any other code required, but without using anystandard Java Collection Framework classes or interfaces (e.g.,List), so that you caniterate over an instance ofClockusing a for-­‐each loop. For example, the followingcode should print the numbers 2, 3, 4, and 5. You do not have to consider the casewhere the hours go past 23. Assume the input you’re given will produce outputwithin the same day (i.e., values between 0-­‐23 only).for (Integer i: new Clock(2,4)) {System.out.println(i);}Q10.Suppose you are designing an Android app that will allow the user to perform taskmanagement. The user can add tasks to the system and can group tasks togetherinto projects. Projects can be added as sub-­‐projects of other projects, nestedarbitrarily deep. Each task has an estimated time for completion that is specifiedwhen the task is constructed. You want to be able to treat individual tasks andprojects in the same way. In particular, you want to be able to get the time neededto complete a task or a project. The time taken to complete a project is the totaltime needed to complete all the tasks in the project or in sub-­‐projects of that project.a)Consider the partially completed code in thelectures/TaskManagerproject.Draw a UML diagram that includes all the classes in theca.ubc.cpsc210.taskmanager.modelpackage and that shows how you willapply the composite pattern to the design of this system.b)Write the complete implementation of theTaskandProjectclasses. Note that allthe tests provided inca.ubc.cpsc210.taskmanager.tests.TestProjectshould pass. Space is also provided on the following page for your answer to thisquestion.

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 5 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Beijing, sub projects

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture