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

OOP-1 Assignment

Here is assignment of oop

Uploaded by

ashtarsyed2
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)
18 views

OOP-1 Assignment

Here is assignment of oop

Uploaded by

ashtarsyed2
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/ 5

Instructor: Ahmed Alhussain Object Oriented Programming 2022– 2023

King Faisal University

College of Computer Science and Information Technology

Object Oriented Programming (OOP1)

Assignment

1. Overview
The purpose of this assignment is to gain practice in the main concepts of object-
oriented (inheritance, encapsulation, polymorphism, abstraction). It also aims to
create, write, and read files and get the file name.
2. The Required Format
The followings are the required format for the “ASSIGNMENT” document.
• User a readable font (e.g., Times New Roman, Cambria, and Arial).
• All pages should be numbered, including the cover page.
• Evaluation Criteria should be included at the end of the document.
• Use the template provided on the blackboard.

Assignment 2 Page 1/4


Instructor: Ahmed Alhussain Object Oriented Programming 2022– 2023

3. Description
Task1:

In your words, write a descriptive essay that describes the main concepts of object-
oriented programming (inheritance, encapsulation, polymorphism, and
abstraction), including each concept's definition and advantages and disadvantages.
Then, how they are implemented; explain your answer by creating a program as an
example for each concept; a screenshot of the source code and the program's output is
required.

Task 2:
Write a java program that allows the user to create a file, write to a file, read from a file
and get the name of the created file.

- Create a class named Assignment2.


- This class has three private instance variables as follows:
• String txt: it is used to store the text that will be saved to the file.
• String path: it is used to store the path of the file.
• int option: it is used to store the option that will be entered by the user.
- This class has one method for each task (first method to write to a file, second
method to read from a file, and the third method to get the file name)
- In the body of the static main method:
• The user will be asked to enter the absolute path of the file.
• The file should be created.
• The user will be asked to choose one of the following options:
1. Write to a file.
2. Read from a file.
3. Get the file name.
4. Exit

Assignment 2 Page 2/4


Instructor: Ahmed Alhussain Object Oriented Programming 2022– 2023

- The user should be asked again and again to choose from the above options unless
the user selects 4. If the user entered 4, Goodbye! Message will be printed out to the
user, and then the program will be stopped.
- The Exception handling should be implemented to handle any exceptions that might
be thrown (e.g., io.IOException: No such file or directory). This type of exception
is thrown if the user enters an absolute path that does not exist. So, as a
programmer, write your code to handle any type of exceptions that might be
occurred, and print out the following message (Invalid Input) to the user in red
colour.

The following figures are an example of exceptions that could be occured:

Assignment 2 Page 3/4


Instructor: Ahmed Alhussain Object Oriented Programming 2022– 2023

The following is an example of the program execution:

Assignment 2 Page 4/4


Instructor: Ahmed Alhussain Object Oriented Programming 2022– 2023

4. SUBMITION GUILDLINES
1. The assignment should be submitted in Blackboard on Saturday (25/05/2024)
(7:00 PM).
2. Late submission is strictly not accepted and will result in “0 mark”.
3. The assignment should be submitted as a word file; it must be named OOP1_
Asgmt#std.docx.
4. Any student who is involved in any sort of copying will be given zero.

Assignment 2 Page 5/4

You might also like