2015-02-11 3 views
0
public class CustomerTest 
{ 
    private static Object CustomerType; 
    public static void main(String args[]) 
    { 
     String msg = ""; 
     ArrayList(Customer) cList; 

     ArrayList<Customer> customerList = new ArrayList<Customer>(); 

     Customer c1 = new Customer ("Jones", new Address("Cooper","Arlington", "Texas", 76019), 12345); 
     Customer c2 = new Customer ("Smith", new Address("Bowen","Arlington", "Texas", 76006), 65489); 
     Customer c3 = new Customer ("willis", new Address("Bowen","Arlington", "Texas",75550), 27589); 

     customerList.add(c1); 
     customerList.add(c2); 
     customerList.add(c3); 
     ArrayList<Course> courseList = new ArrayList<Course>(); 

       Course co1 = new Course ("OnlineCourse",("Java 1","PROGRAMMING", "Davis", 125.00, new Date(1,1,2015), new Date(1,15,2015), "Uta" 2015); 
       Course co2 = new Course ("OnlineCourse","Java 2","Jones", 125.00, new Date(1,1,2015), new Date(1,15,2015)); 
     Course co3 = new Course ("InClassCourse","CanonPictures", "Long", 75.00, new Date(2,5,2015), new Date(3,2,2015)); 

     courseList.add(co1); 
     courseList.add(co2); 
     courseList.add(co3); 

     c1.setCType(Customer.customerType.STUDENT); 
     c2.setCType(Customer.customerType.FACULTY); 
     c3.setCType(Customer.customerType.GOVERNMENT); 


     for (Customer c: customerList) 
     { 
      cList = c.getCustomerList(); 
      for (Customer c: cList) 
      { 
      msg += c.calculateCharge(); 
      } 
     } 
      JOptionPane.showMessageDialog(null, msg); 
    } 
} 

Получение «Не найдено подходящих конструкторов» В курсе c01, co2.Не найдено подходящих конструкторов java error ..?

Это также не позволяет мне установить СТУДЕНТ, ФАКУЛЬТЕТ и т. Д., Это дает мне «не найти символ». У меня 6 классов, и это основной класс. Я объявил все переменные, наборы, попадает в другие классы, и теперь я пытаюсь выполнить основной класс (этот). OKAY Я ДОБАВЛЯЛ КЛАССЫ ОСНОВНОГО ИСПОЛЬЗОВАНИЯ.

public class Course 
{ 

    private String title; 
    private String instructor; 
    private double price; 
    public enum CourseType{PROGRAMMING, MATHEMATICS, PHOTOGRAPHY, MUSIC, PAINTING, MISC}; 
    private CourseType cType; 
    private Date startDate; 
    private Date endDate; 

    public Course() 

    { 
       setTitle(""); 
      setInstructor(""); 
     setPrice(0.0); 
     setCType(CourseType.PROGRAMMING); 
     setStartDate(new Date()); 
     setEndDate(new Date()); 
     } 
    public Course(String title, String instructor, double price, Date startDate, Date endDate) 

    { 
       setTitle(title); 
       setInstructor(instructor); 
       setPrice(price); 
       setStartDate(startDate); 
       setEndDate(endDate);   

    } 
    public void setTitle(String title) 

    { 
     this.title = title; 

    } 
    public void setInstructor(String instructor) 

    { 

     this.instructor = instructor; 

    } 
    public void setPrice(double price) 

    { 
     this.price = price; 

    } 
    public void setCType(CourseType cType) 

    { 
     this.cType = cType; 

    } 
    public void setStartDate(Date startDate) 

    { 
     this.startDate = startDate; 

    } 
    public void setEndDate(Date endDate) 

    { 
     this.endDate = endDate; 

    } 
    public String getTitle() 

    { 
     return title; 

    } 
    public String getInstructor() 

    { 
     return instructor; 

    } 
    public double getPrice() 

    { 
     return price; 

    } 
    public CourseType getCType() 

    { 
     return cType; 

    } 
    public Date getStartDate() 

    { 
     return startDate; 

    } 
    public Date getEndDate() 

    { 
     return endDate; 

    } 
    public double calculateCharge(Customer.CustomerType c) 

    { 
     return 0.0; 

    } 

    public String toString() 

    { 
     return("title" + title + "instructor" + instructor + "price" + price + "cType" + cType); 

    } 
} 

public class Customer 
{ 

    private String name; 
    private Address address; 
    private int accountNumber; 
    public enum CustomerType{STUDENT, FACULTY, GOVERNMENT}; 
    private CustomerType cType; 
    private ArrayList<Course> courseList = new ArrayList<Course>(); 

    public Customer() 

    { 

     setName(""); 
     setAddress(new Address()); 
     setAccountNumber(0); 
    } 
    public Customer(String name, Address address, int accountNumber) 

    { 
     setName(name); 
     setAddress(address); 
     setAccountNumber(accountNumber); 
    } 
    public void setName(String name) 

    { 
     this.name = name; 

    } 
    public void setAddress(Address address) 

    { 
     this.address = address; 

    } 
    public void setAccountNumber(int accountNumber) 

    { 
     this.accountNumber = accountNumber; 

    } 
    public void setCType(CustomerType cType) 
    { 
     this.cType = cType; 

    } 
    public void addCourse(Course course) 

    { 
     courseList.add(course); 

    } 
    public String getName() 

    { 
     return name; 

    } 
    public Address getAddress() 

    { 
     return address; 

    } 
    public CustomerType getCType() 

    { 
     return cType; 

    } 
    public String getCourseList() 

    { 
     return courseList.toString(); 

    } 
    public String toString() 

    { 
     return("name" + name + "Address" + address + "accountnumber" + accountNumber + "CustomerType" + cType + "courseList" + courseList); 

     } 

} 
+0

Отсутствующие запятой возможно? 'новая дата (1,15,2015),« Uta »2015); 'в конце курса c01 строка? –

+0

'ArrayList (Customer)' должен быть 'ArrayList '. –

ответ

0

Это конструкторы, которые вы поставили.

public Course(String title, String instructor, double price, Date startDate, Date endDate) 

public Course() 

И на основе объекта курса c01, похоже, у вас есть пара вопросов. Первая неуместные круглые скобки (и «Uta» 2015, не действителен для конструктора либо.

Course co1 = new Course ("OnlineCourse",("Java 1","PROGRAMMING", "Davis", 125.00, new Date(1,1,2015), new Date(1,15,2015), "Uta" 2015); 

Я не уверен, если это было просто опечатка, но нет подходящих Конструкторов, просто как ошибки состояний.

Попробуйте заменить, что с этим и посмотреть, что получится.

Course co1 = new Course ("Java 1","Davis", 125.00, new Date(1,1,2015), new Date(1,15,2015)); 

для не может найти символьная ошибка, похоже, что вы не можете правильно ссылаться на перечисление.

c1.setCType(Customer.customerType.STUDENT); 

Когда он выглядит, как это должно быть,

c1.setCType(Customer.CustomerType.STUDENT); 

+0

Как я могу опубликовать классы ...? Я новичок в stackoverflow ... – Noah

+0

Измените свой вопрос и добавьте исходный код для других классов. – broot02

+0

Хорошо, я включил два курса. – Noah

Смежные вопросы