0% found this document useful (0 votes)
2 views

Lab Report Questions Unit 3 New Format (1)

The document outlines a series of lab assignments for a BCA Scripting Language course, requiring students to create various classes and interfaces in PHP, implement methods, and validate user input using jQuery. Students are instructed to push their solutions to GitHub, share the repository with the instructor, and include printed documentation of their work. Additionally, the assignments cover topics such as object-oriented programming, AJAX, and web form validation.

Uploaded by

nischealbasnet08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab Report Questions Unit 3 New Format (1)

The document outlines a series of lab assignments for a BCA Scripting Language course, requiring students to create various classes and interfaces in PHP, implement methods, and validate user input using jQuery. Students are instructed to push their solutions to GitHub, share the repository with the instructor, and include printed documentation of their work. Additionally, the assignments cover topics such as object-oriented programming, AJAX, and web form validation.

Uploaded by

nischealbasnet08
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab Report Questions

Instructions:

 Create your new repository on GitHub and push your lab solution to GitHub with new
branch for each lab set.
 Share your repository to [email protected] as a collaborator.
 Print and attach your updated GitHub screenshot into lab set
Format

● Cover (Print)
● GitHub Screenshot
● Lab Question –hand written
● Introduction –hand written
● Syntax and Format –hand written
● Code –hand written
● Output(Print)- With full URL
Lab-3

1. Create a Car class with the following properties and methods:

 Properties: $make, $model, $year.


 Methods:
o start(): Print "Car started."
o displayInfo(): Print the car's make, model, and year.
 Implement Encapsulation : Modify the Car class:
o Make properties private.
o Add getter and setter methods for $make, $model, and $year

 Create a ElectricCar class that extends the Car class,


o Add a new property $batteryCapacity and method charge()
o Add a getDescription() method in the Car class and override it in the
ElectricCar class.
 Create an interface Vehicle with methods startEngine() and stopEngine(). Implement
this interface in the Car class.
2. Create a class called Bicycle.
 The class should have 5 public properties: $brand, $model, $year, $description
and $weight. Default value for the $description property is “Used bicycle” (hint:
you can set it either when declaring the property or through the constructor).

Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
Create getInfo method (a getter) that will return information about the bike in the
following format: “$brand $model ($year)”.
 Create getWeight method that will return weight in grams. Make this method
configurable so that it accepts one argument which by default is false. If it is true,
the weight should be returned in kilograms and if it is false (default), it should
return weight in grams. Create a setter method for the weight property. The
weight property stores the weight in grams. Create two objects from the Bicycle
class and set values for all properties. Print each bike’s information. Print each
bike’s weight in kilograms. Print each bike’s weight in grams.
3. Create a class called Student. The class should have:

 3 public properties: $name, $surname and $country;


 1 private property: $tuition;
 1 protected property: $indexNumber.
o Create getter methods for the name and the surname of the student. Create a
public method helloWorld() that will return “Hello World” string. Create a
protected method helloFamily() that will return “Hello Family” string. Create a
private method helloMe() that will return “Hello me!” string. Create a private
getter method getTuition() that will print the value of the tuition property. Do not
use a constructor with arguments. Create a subclass PartTimeStudent. Add a
public method helloParent() that will call the method helloFamily() from the
Student class. Create objects from both the Student and the PartTimeStudent
classes, and call all the methods within.
4. Create a class called Product.
The class should have 3 properties: $description, $quantity and $price Create constructor
method accepting 3 arguments ($description, $quantity and $price). In the constructor,
when setting these arguments, check if the description is a string and if the quantity and
price are numbers. If they are not, print an error message.
Create setter and getter methods for the $description, $quantity and $price properties.
Create a method called calculatePrice() that will return the product’s price as: $quantity *
$price; Create an object from the Product class. Print all properties in newlines and then
print the result from the calculatePrice() method.
5. Create an interface HasInfo that will have one abstract method called getInfo().
 Create a class called Address that implements the HasInfo interface. The class
should have 3 public properties: street, number and city. Set them through the
constructor. The method getInfo() in this class should return: "Address: street
$street, number $number, city $city". Create a class called Phone that implements
the HasInfo interface.
 The class should have 2 public properties: prefix and number. Set them through
the constructor. The method getInfo() in this class should return: "Number:

Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
$prefix / $number". Create a class called User that implements the HasInfo
interface. The class should have 2 public properties: name and surname. The class
should have 2 private properties: address and phone (instances from the classes
above). The getInfo() method in this class should call the getInfo() methods from
the Address and Phone class respectively.
 The output of this method should be:
"User: $firstName $lastName Address: street $street, number $number,
city $city Number: $prefix / $number"
 Create 1 objects from each class. Call the getInformation method from the User
object to see the above output.
6. Create 3 classes – User, AdminUser and Customer.

class User

 Should have 3 protected properties: $name , $surname and $username;


 Set their values using a constructor method;
 Add 1 protected property $is_admin. Its default value should be false;
 Create a method that checks if the user is admin;
 Create a method that prints the user’s full name. If the user is admin,
print (admin) at the end.

class Customer

 Should extend the User class;


 Add 3 private properties: $city, $state, $country;
 The Customer’s class constructor should have the same parameters as the parent
constructor;
 For the other properties create setter and getter methods;
 Create a method location() that returns ‘$city, $state, $country’.

class AdminUser

 Should extend the User class;


 The constructor should have the same parameters as the parent constructor;
 The constructor should set the value of the $is_admin property to true.

Create objects from each class. Print the full name and is_admin values for each object,
and additionally the location (city, state and country) for the customer objects only.

Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
7. Implement interface in PHP with specific properties (e.g., radius for Circle class and side
for Square class) to ensure that multiple classes provide their own implementations of a
method (e.g., calculateArea), while leveraging these properties for calculations.
8. Create a webpage that has different button to implement different jQuery effect methods :
hide,show,toggle,fadeIn, fadeOut, fadeToggle, slideUp, slideDown, slideToggle,animate
9. Create web page that has registration form, validate according to following rules using
jQuery.
a. Form field: Name, Address, Username, Email, Password, Website, Phone,
Gender(Radio), Course(Dropdown),
b. Name Validation: We check to make sure the name field is not empty and does
not contain any numbers.
c. Username Validation: We check to make sure the username field is not empty and
does not contain any spaces and special character except underscore (_).
d. Phone Validation: We check to make sure the phone field is not empty, does not
contain any character except numbers, and should start with [98/97/96].
e. Gender Validation: We check the gender field is not empty.
f. Address Validation: We check that the address field is not empty.
g. Email Validation: We make sure that the email field is not empty and that it
includes the “@” symbol.
h. Password Validation: We ensure that the password field is not empty and that the
password is at least eight characters long with at least one digit, one upper case
character, one lowercase character and one special character.
i. Course Selection Validation: We check that a course has been selected from a
dropdown list.
10. Create a form asking users to enter userid and password. On submit of the form the page
should submit the data to backend page written in PHP(use ajax). Note that you are
submitting the form using JQuery so page should not reload or redirect. If submitted data
is valid then the login form should show welcome message by hiding the input boxes,
otherwise it should ask the user to try again.
11. Write program to display content from bca.txt (description related to BCA) file into
webpage using AJAX based on JavaScript.
12. Write program to display content from
(https://freetestapi.com/api/v1/movies)URL using AJAX based on
JavaScript with following design
ID Title Poster Year Genre Rating Director Country Language Actors

13. Create webpage that ask username for password reset, when user types username, page
must display either username available or not into database table using AJAX using
XMLHttpRequest object.

Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
14. Create webpage that has country and city dropdown box, when user select country system
must list city name according to country using AJAX using XMLHttpRequest object.
15. Write program to display content from bca.txt (description related to BCA) file into
webpage using AJAX based on JavaScript.
16. Prepare report that shows the steps of installation of WordPress and Joomla CMS. (print)
17. Prepare report that shows the steps of creating post and page into WordPress and Joomla
CMS.(print)
18. Prepare report that shows the steps of create and manage menu WordPress and Joomla
CMS. (print)
19. Create blog website using WordPress or Joomla.

Thank you

Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]

You might also like