Core Java Assignment

Classes and Objects
1. Create class Rectangle
a) data members
– length
– breadth
b) methods
– setDimensions
– area
– perimeter

2. Create class Cube
a) data members
– length
– breadth
– height
b) methods
– setDimensions
– volume

3. Create class Worker
a) data members
– wages
– wdays
b) methods
– setData
– payment

Method Overloading

1. Create class Box
a) data members
– length
– breadth
– height
b) methods
– setDimensions(3 args)
– setDimensions(1 arg)
– volume

Method Returning Value
1. WAP to find total payment of two employeesCreate
Create class Worker
a) data members
– wages
– wdays
b) methods
– setData
– int payment

Constructors
1. Create class Circle and initialize radius using a default constructor
2. Create class Circle and initialize radius using parameterized constructor
3. Create class Circle and define two constructor default and parameterized (Constructor overloading)

Static data members and member functions
1. Create a class Circle and find its area
a) data members
– int radius
– static double pi
b) methods
– area

2. Create a class Bank Account and find interest
a) data members
– int account_number
– int balance
– static double interest_rate
b) methods
– interest (balance * interest_rate * no_of_period / 100.0)
– changeRate (change interest_rate)

How to run linux commands on windows

    1. Cygwin is a Unix-like environment and command-line interface for Microsoft Windows.
      Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment.
      Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.

      Official Site: https://www.cygwin.com/

       

    2. git bash is a shell where: the running process is sh.exe (packaged with msysgit, as share/WinGit/Git Bash.vbs)
      git is a known command$HOME is defined

      Official Site: https://git-scm.com/

  • How to install cygwin on Windows

How to enable ssh login to windows using cygwin

rsync on windows os

rsync: Failed to exec ssh: No such file or directory(2) on windows

nstalling cwrsync, you are likely to get this error  when you try to run this sample command from the command line.

rsync  -avz  -e  ssh ycsoftware@google.com:/home/ycsoftware /cygdrive/z/ycsoftware/

“rsync: Failed to exec ssh: No such file or directory(2)” cwrsync

The reason you are getting this is because for some reason rsync is not able to find the path to the ssh.exe file. You should change it to something like this:

C:/cygwin64/bin/rsync.exe -ar . /cygdrive/c/xampp/htdocs/test2/

Ref: http://ycsoftware.net/rsync-failed-to-exec-ssh-no-such-file-or-directory2-on-windows/

Angular 4 http post with php

Component or Service:

let data = {'title': 'foo',	'body': 'bar', 'userId': 1};
    this.http.post('http://localhost/angular4/angcrud/add_student_action.php', data)
      .subscribe(
        (res:Response) => {
          console.log(res.json());
        },
        err => {
          console.log("Error occured");
        }
      );

 

Php Script:

<?php


$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

header('Content-type: application/json');
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers');
//$res_ar = array("foo"=> $_REQUEST['body']);


echo json_encode($request);

?>


<form #studentForm = "ngForm" (ngSubmit)="addStudentRecord(studentForm.value)">
  First name:<br>
  <input type="text" name="firstname" value="Mickey" ngModel>
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse" ngModel>
  <br><br>
  <input type="submit" value="Submit">
</form>

 

Angular 4 Deployment

Use any of the commands:

  1. ng build
  2. ng build –prod
  3. ng build –prod –base-href /directory-name/sub-directory-name/

Create testing branch on github

  1. add normal git repository
  2. git branch gh-pages
  3. git push -u origin gh-pages

To push on the git repository

  1. git init
  2. git add origin
  3. git add .
  4. git commit -m “Initial Commit”
  5. git push -u origin master
  6. ng build –prod –base-href https://whateveruser.github.io/whateverprojectrepo/
  7. ngh

ng build –prod –base-href https://github.com/whateveruser/whateverprojectrepo/

Ref:

  1. https://www.youtube.com/watch?v=nxV3weqMzYo

.htaccess for production site

RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]

 

OOPS

1. Rectangle Class

Design a class Rectangle
Data Members:

  • length
  • breadth

Member Functions:

  • setDimension()
  • area()
  • perimeter()

2. Worker Class

Design a class Worker
Data Members:

  • wages
  • working_days

Member Functions:

  • setData()
  • payment()

3. Box Class

Design a class Box
Data Members:

  • length
  • breadth
  • height

Member Functions:

  • setDimension()
  • volume()

4. Student Class

Design a class Student
Data Members:

  • roll_number
  • name

Member Functions:

  • setData()
  • getData()

5. Account Class

Design a class Account
Data Members:

  • balance

Member Functions:

  • deposit(amount)
  • withdraw(amount)
  • showBalance()

6. Set Class

Design a class Set that stores three numbers
Member Functions:

  • SUM()
  • MEAN()
  • MAX()
  • MIN()

7. Rectangle Class (Method Overloading – Java / C++)

Design a class Rectangle
Data Members:

  • length
  • breadth

Member Functions:

  • setDimension(int side)
  • setDimension(int length, int breadth)
  • area()
  • perimeter()

8. Box Class (Constructors – Java / C++)

Design a class Box
Data Members:

  • length
  • breadth
  • height

Constructors:

  • Box(int side)
  • Box(int length, int breadth)
  • Box(int length, int breadth, int height)

Member Function:

  • volume()

9. Account Class (Static Data Member)

Design a class Account
Data Members:

  • balance
  • interest_rate (static, default value = 10.25)

Member Function:

  • interest(no_of_years)

10. Student Class (Auto Roll Number)

Design a class Student
Data Members:

  • roll_number (auto-generated)
  • name

Member Functions:

  • getData()

Additional Requirement:

  • Keep track of the total number of students using a static variable.

11. Student Objects Using Array

Design a class Student
Data Members:

  • roll_number
  • name

Member Functions:

  • getData()
  • showData()

Task:

  • Create an array of 5 Student objects and display their details.

12. Student Class with College

Create an array of Student objects
Data Members:

  • roll_no
  • name
  • college

Member Functions:

  • readData()
  • showData()

13. Student & ClassRoom

Design:

  • Student class
  • ClassRoom class

Task:

  • Add a list of students to ClassRoom
  • Display the student list

14. Account & Bank

Design:

  • Account class
  • Bank class

Task:

  • Add a list of accounts to Bank
  • Display account details

15. Java Packages

Create two packages:

  • MyCircle
  • MyRectangle

Data Members:

  • radius (Circle)
  • length, breadth (Rectangle)

Member Functions:

  • area()
  • circumference()
  • perimeter()

16. RBI Class (Java Only)

Design a class RBI
Data Member:

  • balance

Member Functions:

  • RBI() (constructor)
  • deposit(int amount)
  • withdraw(int amount)
  • showBalance()