Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

> Rollable 2. In this project file create a new package named Question 1. In this package, create a Java interface named Rollable to be

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

> Rollable 2. In this project file create a new package named Question 1. In this package, create a Java interface named Rollable to be used for creating any class that represents a wheel. Use the UML class diagram shown in Figure 1 to write your Interface. +rollUp():void +rollDown():void Figure 1 3. This interface describe two methods; rollUp() to roll the wheel one > step up, and rollDown() to roll the wheel one step down. Counter Display 4. The interface Rollable needs to be implemented by any class that +reset():void represents a wheel. +shuffle():void +increase():void 5. In the same package, create another Java interface named +decrease():void Counter Display as shown in Figure 2. This interface will be Figure 2 implemented by any class representing a wheel-based counter. 6. This interface defines four methods; reset() to reset the counter to the minimum value, shufflel) to randomize the positions of the wheels of the counter, increase() to increment the counter, and decrease() to decrement the counter. 7. Do not forget to write inline comments and descriptive comments at the top of each method. > Wheel - value: T 2.2 Question 2 Implement Java Interface (assesses the ET2 CEAB indicator) 1. In the same project file, create a new package and named Question2. 2. In this package, create a new generic type abstract class as shown in Figure 3. 3. This class maintain the value of the wheel stored in the field value. You need to implement the body of the methods set Valuel) and getValue, and define the method reset() and isRolledOver() as abstract methods. +setValue(value: T):void +getValue(): T 4. The purpose of rest() method is to set the value field to the minimum value +reset():void +isRolledOver():Boolean of the wheel, and the purpose of isRolledOver() method is to return whether the last wheel step caused a rollover. Figure 3 5. In the same Question2 package, create a new class and name it Integer Wheel as shown in Figure 4. This class should provide body implementation for the rest() and isRolledOver() methods in addition to a full implementation to the interface Rollable. 6. The constructor with one argument will initialize the minValue by 0, and the maxValue by max, and set the wheel value to max. The constructor with two arguments will initialize the minValue by min and the maxValue by max, and set the wheel value to min. 7. This class records a non-negative count value that is between a minimum and a maximum value. Rolling up the wheel beyond its maximum will roll it over to the minimum value. Rolling down the wheel below its minimum will roll it over to the maximum value. 8. Write a new class named Integer WheelCounter that implements the Counter Display interface and references the Integer Wheel class, see Figure 5 above. This class maintains a collection of three wheels of type IntegerWheel. 9. Implement the toString() method to return a string that represent the Integer WheelCounter object as shown in the given video Clock Demo.mp4. > Wheel - value: T > Rollable > CounterDisplay +reset():void +shuffle():void +increase():void +decrease():void +setValue(value: T):void +getValue(): T +reset():void +isRolledOver():Boolean +rollUp():void +rollDown():void IntegerWheelCounter - integerWheel: IntegerWheels[] - noOfWheels: int Integer Wheel - minValue: int - maxValue: int + IntegerWheelCounter Integer Wheel wheelThree, Integer Wheel wheelTwo, Integer Wheel wheelOne) Integer Wheel(max: int) + Integer Wheel(min: int, max: int) + getMin(): int + getMax(): int + toString(): String Figure 4 Figure 5 10. Do not forget to add inline comments and descriptive comments at the top of each method. 11. Now, add the given Java class Clock Demo.java to your project, then compile and run. Without any changes in this class, you should have an output like the one shown in the given video Clock Demo.mp4. 12. Then add the given Java class Timer Demo.java to your project, compile and run. Again, without any changes in this class, you should have an output like the one shown in the given video Timer Demo.mp4. 1. In this question you will develop a desktop date display program with four wheels, one for the day of the week, one for the month, one for the day, and one for the year. 2. You will use the abstract class Wheel and the interface Rollable to create four new classes: YearWheel, Month Year, DayYear, and Week DaysWheel. In addition, you will use the interface Counter Display to create one more class called CalendarCounter. These five new class should follow the UML class diagram shown in Figure 6. 3. In the same project, create a new package and name it Question3. In this package you will write these five classes. 4. The class diagram shown in Figure 6, will help you to construct your program quickly, however, the numbers and the names of the fields and the methods of the four wheels are not given. So, you will implementation these four wheels on your own, but again it should follow this UML diagram. > Wheel - value: T > Rollable > Counter Display +reset():void +shuffle():void +increase():void +decrease():void +setValue(value: T):void +getValue(): T +reset():void +isRolledOver():Boolean +rollUp():void trollDown():void Calendar Counter Year Wheel yearWheel: Year Wheel month Wheel: Month Wheel dayWheel: DayWheel weekDaysWheel: WeekDays Wheel Month Wheel + CalendarCounter(initialMonth: int, initialDay: int, initial Year: int) DayWheel + toString(): String WeekDays Wheel Figure 6 5. Note that, the YearWheel class should be able to tell whether it is a leap year, while a Month Wheel class can report the months length, i.e., 28, 29, 30, or 31. The DayWheel class needs to know the last day of a month so it can rollover correctly. The Week DaysWheel class uses Zeller's congruence (see Wikipedia) to determine the day on which a given date falls. 6. The constructor of Calendar Counter class takes the values of the month, year and day as parameters and initializes the four objects yearWheel, month Wheel, dayWheel, and weekDaysWheel. 7. The toString() method of the CalendarCounter class should return a string that represent the date format as shown in Figure 7 below. 8. The reset() method of the Calendar Counter class should reset the four wheels to their initial values. 9. To test your program, add the given Java class Desktop Calendar.java to your project, then compile and run you should have an output like the one shown below in Figure 7. 10. Note that, it is not allowed to change, delete, or add any code of the DesktopCalendar.java file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions