Hi.
The following code snippets got some errors in there, Netbeans says. Can somebody tell me what, and why, so that I understand the errors, please?
Database.Java
The first "private person" gives me an error. Why is that?
Date.JavaCode:package Test; public class Database { private person[] list; private int numberOfRecords; public Database() { throw new RuntimeException("Compiled Code"); } public void add(String lastName, String firstName, int month, int day, int year) { //compiled code throw new RuntimeException("Compiled Code"); } public int find(String firstName, String lastName, int month, int day, int year) { throw new RuntimeException("Compiled Code"); } public void printList() { throw new RuntimeException("Compiled Code"); } }
gives me an error for exit(1); and return month==theOtherDate.month && day==theOtherDate.day && year==year; ??
Person.JavaCode:ackage Test; import java.language.*; public class Date { private int day; private int month; public int year; public Date(int m, int d, int y) { setDay(d); setMonth(y); setYear(y); } private int getDay() { return day; } public int getMonth() { return month; } public int getYear() { return month; } public void setDay(int d) { if( d>0 && d<=30) // assume there are 30 days in a month { day =d; } else { System.out.println("Improper user input. Day must be in [1,30]"); exit(1); } } public void setMonth(int m) { if( m>=1 && m<=12) { month =m; } else { System.out.println("Improper user input. Month must be in [1,12]"); System.exit(1); } } public void setYear(int y) { if( y>1900 && y<2050) { year =y; } else { System.out.println("Improper user input. Year must be in [1901,2049]"); System.exit(1); } } public int equals(Date theOtherDate) { return month==theOtherDate.month && day==theOtherDate.day && year==year; } public String toString() { return month + "/" + day + "/" + year; } }
This gives me an error for the first 3 private strings ( firstname, lastname, birthdate) Any ideas?
I appreciate your help!Code:package assignment2; class Person { private string firstName; private string lastName; private Date birthDate; public Person(String fN, String lN, int month, int day, int year) { //compiled code throw new RuntimeException("Compiled Code"); } public boolean equals(Person theOtherPerson) { //compiled code throw new RuntimeException("Compiled Code"); } public boolean equal(String fN, String lN, int month, int day, int year) { //compiled code throw new RuntimeException("Compiled Code"); } public String toString() { //compiled code throw new RuntimeException("Compiled Code"); } }




Reply With Quote