0% found this document useful (0 votes)
84 views4 pages

LAB Final: CMPS242: Exercise 1

This document outlines two lab exercises for a CMPS242 Object Oriented Programming course. The first exercise involves implementing classes for a Video and VideoStore with various methods like checking videos in/out, adding ratings, and listing inventory. The second exercise involves implementing geometric shape classes including an interface for shapes, a Circle class, and ResizableCircle class that extends Circle while also implementing a Resizable interface.

Uploaded by

Zaid Alobeidy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views4 pages

LAB Final: CMPS242: Exercise 1

This document outlines two lab exercises for a CMPS242 Object Oriented Programming course. The first exercise involves implementing classes for a Video and VideoStore with various methods like checking videos in/out, adding ratings, and listing inventory. The second exercise involves implementing geometric shape classes including an interface for shapes, a Circle class, and ResizableCircle class that extends Circle while also implementing a Resizable interface.

Uploaded by

Zaid Alobeidy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

LAB Final: CMPS242

Beirut Arab University Course: Object Oriented Programming


Faculty of Science Semester: Spring 2018-2019
Mathematics and Computer Science Time: T 12-3
Date: 07/05/2019
Department
TA: Lama Soboh and Mousbah Arabi
Lab Final

Exercise 1:

Consider the following UML:

Video VideoStore
Title: String videoCount:int
checkedOut: Boolean:false capacity: int
averageRating: double catalogue: Video[]
ratingSum: int addVideo(String title):void
ratingCount: int checkOutVideo(int video):void
addRating(int rate):void returnVideo(int video):void
getRating():double rateVideo(int video, int
checkOut():void rating):void
returnToStore():void ratingForVideo(int video):double
isCheckedOut():Boolean getVideoByTitle(String title): int
getVideoByIndex(int index): String
extendCatalogue()
1. Implement class Video:

Attributes: Title, checkedOut, averageRating, ratingSum, ratingCount.

Methods:

1. The needed setters / getters.


2. addRating(int rate), lets the user add a rating for the video , it adds this
rating to the rating sum and calculates the average rating of the video.
3. getRating(), gets the average rating of a certain video.
4. checkOut(), sets video to checked out
5. returnToStore(), sets video not checked out
6. isCheckedOut(), returns the checked out value

Page | 1
2. Implement class VideoStore:

Attributes:
 VideoCount, counts the number of videos.
 Capacity initially set to four that is the maximum number of videos in
the video store.
 Define the array of objects catalogue that has initially a capacity of
four videos.

Methods:

1. The needed setters/getters


2. checkOutVideo(int video) , sets the value of checked out for a certain
video.
3. returnVideo(int video) , return the specified video number into the
store.
4. rateVideo(int video, int rating) , adds a specific rating for a certain
video number.
5. ratingForVideo(int video), get the rating for the specified video
number.
6. getVideoByTitle(String title) , gets the number of the video with the
specified title, if the video is not found return zero.
7. getVideoByIndex(int index) ,get the title of the video with the
specified index, if the video is not found , a message should be printed
stating that the video with the specified index was not found.
8. listInventory(), it will prints all the details about the contents of the
catalogue, i.e: the video title, rating & checked out status.
9. addVideo(String title) , add a video to the catalogue and set the title of
the video, in case the shelves are full you should call function
extendCatalogue() and then add the video to the catalogue.
10.extendCatalogue() , in case we need to add a video and the number of
items in array catalogue is full , then we call this function to extend
the array , with a size double of that of the original one.
Note that you should not lose the items that were originally added to
the catalogue before incrementing its size.

3. Implement Class VideoLauncher

 Create a video store.

Page | 2
 Add 5 videos to it.
 Set a rating for each video.
 Test all the implemented methods for both classes.

Exercise 2:

Write a Java program that implements the classes in the following UML.

1. Write the interface called GeometricObject, which declares


two abstract methods: getParameter() and getArea(), as specified in the
class diagram.

2. Write the implementation class Circle, with a protected variable radius, which
implements the interface GeometricObject.

3. Write a test program called TestCircle to test the methods defined in Circle.

4. The class ResizableCircle is defined as a subclass of the class Circle, which


also implements an interface called Resizable, as shown in class diagram. The
interface Resizable declares an abstract method resize(), which modifies the
dimension (such as radius) by the given percentage. Write the
interface Resizable and the class ResizableCircle.
Page | 3
5. Write a test program called TestResizableCircle to test the methods defined
in ResizableCircle.

Page | 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy