class clash issue
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package l2a;
|
package l2a.employees;
|
||||||
|
|
||||||
public class Employee {
|
public class Employee {
|
||||||
String ID;
|
String ID;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package l2a;
|
package l2a.employees;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,6 +19,7 @@ public class EmployeeFileRead {
|
|||||||
System.out.print("Employee count: ");
|
System.out.print("Employee count: ");
|
||||||
int n = input.nextInt();
|
int n = input.nextInt();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
System.out.println("\nEmployee " + (i + 1));
|
||||||
System.out.print("ID: ");
|
System.out.print("ID: ");
|
||||||
String ID = input.next();
|
String ID = input.next();
|
||||||
System.out.print("Name: ");
|
System.out.print("Name: ");
|
||||||
@@ -70,7 +71,9 @@ public class EmployeeFileRead {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void print(List<Employee> employees) {
|
public static void print(List<Employee> employees) {
|
||||||
|
int ind = 1;
|
||||||
for (Employee employee : employees) {
|
for (Employee employee : employees) {
|
||||||
|
System.out.println("\nEmployee " + ind++);
|
||||||
System.out.println("ID: " +employee.getID());
|
System.out.println("ID: " +employee.getID());
|
||||||
System.out.println("Name: " +employee.getName());
|
System.out.println("Name: " +employee.getName());
|
||||||
System.out.println("Department: " +employee.getDepartment() );
|
System.out.println("Department: " +employee.getDepartment() );
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package l2a;
|
package l2a.name_card;
|
||||||
|
|
||||||
|
|
||||||
public class NameCard {
|
public class NameCard {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package l2a;
|
package l2a.name_card;
|
||||||
|
|
||||||
public class NameCardTest {
|
public class NameCardTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package l2a;
|
package l2a.shaperead1;
|
||||||
|
|
||||||
public class shapeRead {
|
public class shapeRead {
|
||||||
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package l2a.shaperead2;
|
||||||
|
|
||||||
|
interface Nameable {
|
||||||
|
String getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Area {
|
||||||
|
double calArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Volume extends Area {
|
||||||
|
double calVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Shape implements Nameable {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Point extends Shape {
|
||||||
|
protected double x;
|
||||||
|
protected double y;
|
||||||
|
|
||||||
|
Point(double x, double y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Point";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Point (" + x + ", " + y + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Circle extends Point implements Area {
|
||||||
|
protected double r;
|
||||||
|
|
||||||
|
Circle(double x, double y, double r) {
|
||||||
|
super(x, y);
|
||||||
|
this.r = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Circle";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double calArea() {
|
||||||
|
return (r * r * Math.PI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Circle with center at (" + x + ", " + y + ") and radius " + r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cylinder extends Circle implements Volume {
|
||||||
|
protected double h;
|
||||||
|
|
||||||
|
Cylinder(double x, double y, double r, double h) {
|
||||||
|
super(x, y, r);
|
||||||
|
this.h = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Cylinder";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double calVolume() {
|
||||||
|
return super.calArea() * h;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double calArea() {
|
||||||
|
return 2 * (r * r * Math.PI) + (2 * r * Math.PI) * h;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Cylinder with center at (" + x + ", " + y + "), radius " + r + ", and height " + h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class shapeRead2 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Shape[] shapes = new Shape[3];
|
||||||
|
shapes[0] = new Point(1, 2);
|
||||||
|
shapes[1] = new Circle(1, 2, 3);
|
||||||
|
shapes[2] = new Cylinder(1, 2, 3, 5);
|
||||||
|
for (Shape shape : shapes) {
|
||||||
|
System.out.println(shape); // Calls overridden toString()
|
||||||
|
System.out.println("Shape name: " + shape.getName());
|
||||||
|
if (shape instanceof Circle) {
|
||||||
|
System.out.println("Circle area: " + ((Circle) shape).calArea());
|
||||||
|
}
|
||||||
|
if (shape instanceof Cylinder) {
|
||||||
|
System.out.println("Cylinder area: " + ((Cylinder) shape).calArea());
|
||||||
|
System.out.println("Cylinder volume: " + ((Cylinder) shape).calVolume());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// System.out.println(shapes[0].toString()); // Should call Point's toString()
|
||||||
|
// System.out.println(shapes[1].toString()); // Should call Circle's toString()
|
||||||
|
// System.out.println(shapes[2].toString()); // Should call Cylinder's toString()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package lda;
|
package lda;
|
||||||
|
|
||||||
|
import lda.dialog.dialogeyTestMain;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("i hate this so much");
|
System.out.println("i hate this so much");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package lda;
|
package lda.dialog;
|
||||||
|
|
||||||
public class DialogueObject {
|
public class DialogueObject {
|
||||||
String caseName;
|
String caseName;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package lda;
|
package lda.dialog;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
class dialogeyTestMain {
|
public class dialogeyTestMain {
|
||||||
|
|
||||||
static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
DialogueObject[] dialogues = new DialogueObject[4];
|
DialogueObject[] dialogues = new DialogueObject[4];
|
||||||
|
|
||||||
dialogues[0] = new DialogueObject(
|
dialogues[0] = new DialogueObject(
|
||||||
Reference in New Issue
Block a user