0% found this document useful (0 votes)
10 views14 pages

Assignment 3

r4c encryption and decryption python

Uploaded by

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

Assignment 3

r4c encryption and decryption python

Uploaded by

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

ASSIGNMENT 3

OBJECT ORIENTED PROGRAMMING

Name: Harris
9/17/2024
Ahmad
Registration: FA23-BCT-
012
Submitted to: Ma’am
Saneeha
Department: Computer
Science

(FA23-BCT-012) HARRIS AHMAD KHOKHAR


CYBER AND TECHNOLOGY
Account Class:

public class account {


double balance;
int yearOfOpening;
String cnic;

public account() {
balance = 0.0;
yearOfOpening = 2024;
cnic = "";
}

public account(double initialBalance) {


balance = initialBalance;
yearOfOpening = 2024;
cnic = "";
}

public account(double initialBalance, int openingYear) {


balance = initialBalance;
yearOfOpening = openingYear;
cnic = "";
}

public void setValues(double x, int y, String z){


balance = x;
yearOfOpening = y;
cnic = z;
}
public void display(){
System.out.println("Balance: " + balance);
System.out.println("Year of opening: " + yearOfOpening);
System.out.println("CNIC: " + cnic);
}
public void withdraw(double amount){
balance -= amount;
}
public void deposit(double amount){
balance += amount;
}
public int ageOfAccount(){
int age = 2024 - yearOfOpening;
return age;
}
}

Quadratic Class:

public class quadratic {


double a;
double b;
double c;
public quadratic(double x, double y, double z){
a = x;
b = y;
c = z;
}

public quadratic(double x, double y){


a = x;
b = y;
c = 0;
}

public quadratic(){
a = 0;
b = 0;
c = 0;
}

public void setValues(double x, double y, double z){


a = x;
b = y;
c = z;
}
public void display(){
System.out.println("a : "+a);
System.out.println("b : "+b);
System.out.println("c : "+c);
}
public double discriminant(){
return (b*b)-(4*a*c);
}
public boolean disccheck(){
if((b*b)-(4*a*c) > 100){
return true;
}
else {
return false;
}
}
}

Rectangle Class

package lab3;

public class rectangle {


double l;
double w;

public rectangle(){
l = 0;
w = 0;
}

public rectangle(double a){


l = a;
w = a;
}

public rectangle(double a, double b){


l = a;
w = b;
}

public void setValues(double a, double b){


l = a;
w = b;
}
public void display(){
System.out.println("Length is: " + l);
System.out.println("Width is: " + w);
}
public double area(){
return l * w;
}
public boolean check(){
if (l == w){
return true;
}
else {
return false;
}
}
}

Point class

package lab3;

public class point {


double x;
double y;

public point() {
x = 0;
y = 0;
}

public point(double a, double b) {


x = a;
y = b;
}

public void setValues(double a, double b){


x = a;
y = b;
}
public void display(){
System.out.println("("+x+","+y+")");
}
public void move(double a, double b){
x += a;
y += b;
}
public boolean check(){
if (x == 0 & y == 0){
return true;
}
else {
return false;
}
}
}

Book class
package lab3;

public class book {


String author;
String[] chapters = new String[5];

public book() {
author = "";
chapters = new String[5];
}

public book(String n, String[] ch) {


author = n;
chapters = ch;
}

public void setValues(String n , String[] ch){


author = n;
chapters = ch;
}
public void display(){
System.out.println("Author name: " + author);
for (int i = 0; i < chapters.length; i++){
System.out.print(chapters[i] + ", ");
}
System.out.println();
}
public boolean check(){
if (String.valueOf(author.charAt(0)).equals("A")){
return true;
}
else {
return false;
}
}
public boolean toSearch(String search){
boolean flag = false;
for (int i = 0; i < chapters.length; i++) {
if (search.equals(chapters[i])) {
flag = true;
}
}
return flag;
}
}
Student class

package lab3;

public class student {


String name;
double gpa;
String email;
String[] subjects = new String[5];

public student() {
name = "";
gpa = 0.0;
email = "";
subjects = new String[5];
}

public student(String n, double g) {


name = n;
gpa = g;
email = "";
subjects = new String[5];
}

public student(String n, double g, String e) {


name = n;
gpa = g;
email = e;
subjects = new String[5];
}

public void setValues(String n , double g, String e , String[] s){


name = n;
gpa = g;
email = e;
subjects = s;
}
public void display(){
System.out.println("Name: " + name);
System.out.println("CGPA: " + gpa);
System.out.println("Email: " + email);
for (int i = 0; i < 5; i++){
System.out.print(subjects[i] + ", ");
}
System.out.println();
}
public boolean toSearch(String search){
boolean flag = false;
for (int i = 0; i < subjects.length; i++) {
if (search.equals(subjects[i])) {
flag = true;
}
}
return flag;
}
public boolean prob(){
boolean flag = false;
if (gpa < 2){
flag = true;
}
return flag;
}
public boolean validity(){
boolean flag = false;
String sub = email.substring((email.length()-9), (email.length()-
1));
if (sub.equals("@gmail.com")){
flag = true;
}
return flag;
}
}

University class

package lab3;

public class university {


String uni;
String location;
String rector;
String[] departments = new String[20];

public university() {
uni = "";
location = "";
rector = "";
departments = new String[20];
}
public university(String u, String l) {
uni = u;
location = l;
rector = "";
departments = new String[20];
}

public university(String u, String l, String r) {


uni = u;
location = l;
rector = r;
departments = new String[20];
}

public void setValues(String u, String l , String r, String[] d){


uni = u;
location = l;
rector = r;
departments = d;
}
public void display(){
System.out.println("University name: " + uni);
System.out.println("Location: " + location);
System.out.println("Rector name: " + rector);
for (int i = 0; i < 20; i++){
if (departments[i] != null){
System.out.println(departments[i] + ", ");
}
}

System.out.println();
}
public void addDepartment(String dep){
for (int i = 0; i < 20; i++){
if (departments[i] == null){
departments[i] = dep;
}
}
}
public boolean checkFed(){
if (location.equals("Islamabad")){
return true;
}
else {
return false;
}
}
public boolean checkProvin(){
if (location.equals("Lahore")){
return true;
}
else {
return false;
}
}
public boolean toSearch(String search){
boolean flag = false;
for (int i = 0; i < departments.length; i++) {
if (search.equals(departments[i])) {
flag = true;
}
}
return flag;
}
}

SIGNLE RUNNER

package lab3;

public class singlerunner {


public static void main(String[] args) {
account a1 = new account();
a1.setValues(5000, 2010, "36302-1093337-4");
System.out.println("State of the object a1 : ");
a1.display();
a1.withdraw(500);
System.out.println("Amount after withdrawal: " + a1.balance);
a1.deposit(1500);
System.out.println("Amount after deposit: " + a1.balance);
System.out.println("Age of account: " + a1.ageOfAccount() +
"years");
System.out.println(" \
n********************************************************\n");

quadratic q1 = new quadratic();


q1.setValues(2.37, 15.7, 6.4);
System.out.println("State of the object q1: ");
q1.display();
System.out.println("Discriminant of this equation : " +
q1.discriminant());
System.out.println("Is the discriminant Greater than 100? " +
q1.disccheck());
System.out.println(" \
n********************************************************\n");

rectangle r1 = new rectangle();


r1.setValues(10, 15);
System.out.println("The current state of the object is: ");
r1.display();
System.out.println("The area of the rectangle is: " + r1.area());
System.out.println("Is the Rectangle a Square? " + r1.check());
System.out.println(" \
n********************************************************\n");

point p1 = new point();


p1.setValues(3.2 , 4.6);
System.out.println("The current state of the object p1: ");
p1.display();
System.out.println("Is the point at origin? " + p1.check());
p1.move(-2, -1.7);
System.out.println("The state of the object has become: ");
p1.display();
System.out.println(" \
n********************************************************\n");

book b1 = new book();


String[] list = {"Muhammad", "Tuaha", "Ijaz", "Saim", "Ali"};
b1.setValues("Tuaha", list);
System.out.println("The state of the object b1 is: ");
b1.display();
System.out.println("Does the author name start with A? " +
b1.check());
System.out.println("Is you search Available? " +
b1.toSearch("Tuaha"));
System.out.println(" \
n********************************************************\n");

student s1 = new student();


String[] list1 = {"Muhammad", "Tuaha", "Ijaz", "Saim", "Ali"};
s1.setValues("Tuaha", 3.83, "[email protected]", list1);
System.out.println("The current status of the student s1: ");
s1.display();
System.out.println("Is the subject you searched, there? " +
s1.toSearch("Tuaha"));
System.out.println("Is there a prob? " + s1.prob());
System.out.println("Is the Email valid? " + s1.validity());
System.out.println(" \
n********************************************************\n");

university u1 = new university();


String[] department = new String[20];
department[0] = "a";
department[1] = "b";
department[2] = "c";

u1.setValues("Comsats", "Islamabad", "Tuaha", department);


System.out.println("The status of the university is: ");
u1.display();
u1.addDepartment("d");
System.out.println("Is it in Federal Capital? " + u1.checkFed());
System.out.println("Is it in Provincial Capital? " +
u1.checkProvin());
System.out.println("Is your search there? " +
u1.toSearch("tuaha"));
System.out.println("Status after adding department: ");
u1.display();
}
}

OUTPUT:

You might also like