Whenever I try to run this program a window appears with Class not Found in Main project. Thanks in Advance.
*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Assignment10;
/**
*
* @author goodf
*/
public class Assignment10{
public class SimpleGeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** Construct a default geometric object */
public SimpleGeometricObject() {
dateCreated = new java.util.Date();
}
/** Construct a geometric object with the specified color
* and filled value */
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}
/** Return color */
public String getColor() {
return color;
}
/** Set a new color */
public void setColor(String color) {
this.color = color;
}
/** Return filled. Since filled is boolean,
its get method is named isFilled */
public boolean isFilled() {
return filled;
}
/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Get dateCreated */
public java.util.Date getDateCreated() {
return dateCreated;
}
/** Return a string representation of this object */
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color +
" and filled: " + filled;
}
}
public static class Square extends SimpleGeometricObject {
private double side;
public Square()
{
side=0;
}
public Square(double s){
super();
side=s;
}
public double getSide(){
return side;
}
public void setSide(double s){
side=s;
}
public double getArea(){
return (side*side);
}
public double getPerimeter(){
return(4*side);
}
public static void Assignment10(String[] args) {
Square rectangle = new Square();
rectangle.setSide(30);
rectangle.setColor("White");
rectangle.setFilled(true);
System.out.println("Color: " + rectangle.getColor() + "Date
Created: " + rectangle.getDateCreated() + "Filled: " +
rectangle.isFilled()+
"Area: "+rectangle.getArea()+"Perimeter:
"+rectangle.getPerimeter());
// TODO code application logic here
}
}
If you have any doubts, please ask in the comments, I will try to solve it as soon as possible. If you find my answer helpful, do UPVOTE.Thanks
The corrected code is given below:
Assignment10.java
class SimpleGeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** Construct a default geometric object */
public SimpleGeometricObject() {
dateCreated = new java.util.Date();
}
/** Construct a geometric object with the specified color
* and filled value */
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}
/** Return color */
public String getColor() {
return color;
}
/** Set a new color */
public void setColor(String color) {
this.color = color;
}
/** Return filled. Since filled is boolean,
its get method is named isFilled */
public boolean isFilled() {
return filled;
}
/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Get dateCreated */
public java.util.Date getDateCreated() {
return dateCreated;
}
/** Return a string representation of this object */
public String toString() {
return "created on " + dateCreated + "\n color: " + color +
" and filled: " + filled;
}
}
class Square extends SimpleGeometricObject {
private double side;
public Square()
{
side=0;
}
public Square(double s){
super();
side=s;
}
public double getSide(){
return side;
}
public void setSide(double s){
side=s;
}
public double getArea(){
return (side*side);
}
public double getPerimeter(){
return(4*side);
}
}
public class Assignment10{
public static void main(String[] args) {
Square rectangle = new Square();
rectangle.setSide(30);
rectangle.setColor("White");
rectangle.setFilled(true);
System.out.println("Color: " + rectangle.getColor() + " Date Created: " + rectangle.getDateCreated() + " Filled: " + rectangle.isFilled()+
" Area: "+rectangle.getArea()+" Perimeter: "+rectangle.getPerimeter());
// TODO code application logic here
}
}
Code Snippet:
Note: There can be only one public class in a java file with the same as file name.
main function was missing
Output:
The code is running proprly now. I have attached the output
Get Answers For Free
Most questions answered within 1 hours.