1. Create a paragraph of more than 300 words including punctuations. You need to extract following from this paragraph,
- Puntuation
- Fillers
- Vowels
Note: You can also print these punctuations, their offset, and count of any punctuation.
2. Find point of intersection in a right rectangle (Note: right rectangle is one which do have all angles @ 90 degree).
Showing posts with label Class 6. Show all posts
Showing posts with label Class 6. Show all posts
Monday, July 11, 2011
Rectangle
package com.evs.objava33.class6;
public class Rectangle {
Line width, height;
public Rectangle(final Point start1, final Point start2, final Point end1,
final Point end2) {
width = new Line(start1, end1);
height = new Line(start2, end2);
}
public Rectangle(final Line width, final Line height) {
this.width = width;
this.height = height;
}
public Rectangle(final Rectangle rec) {
this.width = rec.width;
this.height = rec.height;
}
public double area() {
return width.length() * height.length();
}
}
public class Rectangle {
Line width, height;
public Rectangle(final Point start1, final Point start2, final Point end1,
final Point end2) {
width = new Line(start1, end1);
height = new Line(start2, end2);
}
public Rectangle(final Line width, final Line height) {
this.width = width;
this.height = height;
}
public Rectangle(final Rectangle rec) {
this.width = rec.width;
this.height = rec.height;
}
public double area() {
return width.length() * height.length();
}
}
Point
package com.evs.objava33.class6;
public class Point {
double x;
double y;
Point(double x, double y) {
this.x = x;
this.y = y;
}
// return_type method_name ( parameter_list ) ;
double getX() {
return x;
}
void setX(double x) {
this.x = x;
}
double getY() {
return y;
}
void setY(double y) {
this.y = y;
}
public double distance(Point p1, Point p2) {
return Math.sqrt((p2.getY() - p1.getY()) * (p2.getY() - p1.getY())
+ (p2.getX() - p1.getX()) * (p2.getX() - p1.getX()));
}
public double distance(Point p) {
return distance(this, p);
}
public String toString() {
return "Point [x=" + x + ", y=" + y + "]";
}
public static void main(String[] args) {
Point point = new Point(3, 4);
System.out.println(point);
}
}
public class Point {
double x;
double y;
Point(double x, double y) {
this.x = x;
this.y = y;
}
// return_type method_name ( parameter_list ) ;
double getX() {
return x;
}
void setX(double x) {
this.x = x;
}
double getY() {
return y;
}
void setY(double y) {
this.y = y;
}
public double distance(Point p1, Point p2) {
return Math.sqrt((p2.getY() - p1.getY()) * (p2.getY() - p1.getY())
+ (p2.getX() - p1.getX()) * (p2.getX() - p1.getX()));
}
public double distance(Point p) {
return distance(this, p);
}
public String toString() {
return "Point [x=" + x + ", y=" + y + "]";
}
public static void main(String[] args) {
Point point = new Point(3, 4);
System.out.println(point);
}
}
Line
package com.evs.objava33.class6;
public class Line {
// double x1, y1, x2, y2;
Point start, end;
public Line(double x1, double y1, double x2, double y2) {
start = new Point(x1, y1);
end = new Point(x2, y2);
}
public Line(final Point start, final Point end) {
this.start = start;
this.end = end;
}
public Line(final Line line) {
this.start = line.start;
// this.start = new Point(line.start.getX(), line.start.getY());
this.end = line.end;
}
public double length() {
return start.distance(end);
}
public String toString() {
return "Line [start=" + start + ", end=" + end + "]";
}
}
public class Line {
// double x1, y1, x2, y2;
Point start, end;
public Line(double x1, double y1, double x2, double y2) {
start = new Point(x1, y1);
end = new Point(x2, y2);
}
public Line(final Point start, final Point end) {
this.start = start;
this.end = end;
}
public Line(final Line line) {
this.start = line.start;
// this.start = new Point(line.start.getX(), line.start.getY());
this.end = line.end;
}
public double length() {
return start.distance(end);
}
public String toString() {
return "Line [start=" + start + ", end=" + end + "]";
}
}
Subscribe to:
Posts (Atom)