Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Case A Video Store (AVS) runs a series of fairly standard video stores. Before a

ID: 668822 • Letter: C

Question

Case

A Video Store (AVS) runs a series of fairly standard video stores. Before a video can be put on the shelf, it must be cataloged and entered into the video database. Every customer must have a valid AVS customer card in order to rent a video. Customers rent videos for three days at a time. Every time a customer rents a video, the system must ensure that they do not have any overdue videos. If so, the overdue videos must be returned and an overdue fee paid before customer can rent more videos. Likewise, if the customer has returned overdue videos, but has not paid the overdue fee, the fee must be paid before new videos can be rented. Every morning, the store manager prints a report that lists overdue videos. If a video is two or more days overdue, the manager calls the customer to remind them to return the video. If a video is returned in damaged condition, the manager removes it from the video database and may sometimes charge the customer.

1. Identify 3 classes from the case above. For each of the classes identified in question, identify 2 methods for each class. Be sure to include any arguments that would be required to perform the method.  

2. In the case above, identify an example of generalization (superclass and subclass).

3. Explain the concept of polymorphism using an example in the case above

Explanation / Answer

POLYMORPHISM:
>Polymorphism literally means taking more than one form .polymorphism is a characteristic of being able to assign a different behavior or value in a subclass, to something that was declared in a parent class.

There are two types of polymorphism:

1)Method overloading
>The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures
>Overloading is also known as Compile time polymorphism
example:

class Overload
{
void demo (int a)
{
System.out.println ("a: " + a);
}
void demo (int a, int b)
{
System.out.println ("a and b: " + a + "," + b);
}
double demo(double a)
{
System.out.println("double a: " + a);
return a*a;
}
}
class MethodOverloading
{
public static void main (String args [])
{
Overload Obj = new Overload();
double result;
Obj .demo(30);
Obj .demo(40, 50);
result = Obj .demo(5.5);
System.out.println("O/P : " + result);
}
}

COSTRUCTOR OVERLOADING:
>The Java programming language supports overloading constructor, You cannot write two constructors that have the same number and type of arguments for the same class, because the platform would not be able to tell them apart. Doing so causes a compile-time error

example:

public class Student
{
String name;
int age;
String email;
public Studtent(String name,int age)
{
this.name=name;
this.age=age;
}
public Studtent (String name,int age, String email)
{
this.name=name;
this.age=age;
this.email=email;
}
public void display()
{
System.out.println(name);
System.out.println(age);
System.out.println(email);
}
public static void main(String[] args)
{
Student s1=new Student("mark", 40);
Student s2=new Student("Vradeep", 35,"vradeep@yahoo.com");
s1.display();
s2.display();  
}
}

2)METHOD OVERRDIDNG:

>Child class has the same method as of base class. In such cases child class overrides the parent class method without even touching the source code of the base class. This feature is known as method overriding.
Example:

public class BaseClass
{
public void methodToOverride() //Base class method
{
System.out.println ("I'm the method of BaseClass");
}
}
public class DerivedClass extends BaseClass
{
public void methodToOverride() //Derived Class method
{
System.out.println ("I'm the method of DerivedClass");
}
}
public class TestMethod
{
public static void main (String args [])
{
// BaseClass reference and object
BaseClass obj1 = new BaseClass();
// BaseClass reference but DerivedClass object
BaseClass obj2 = new DerivedClass();
// Calls the method from BaseClass class
obj1.methodToOverride();
//Calls the method from DerivedClass class
obj2.methodToOverride();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote