2012-11-02 2 views
1

그래서 고객이 제품을 구입하여 장바구니에 추가 할 수있는 웹 사이트를 시뮬레이트하는 프로그래밍 클래스의 코드를 작성하고 있습니다. 나는 Product and Cart 클래스를 만들었습니다. 둘 다 일부 디렉토리에 있으며 .class 파일은 동일한 패키지에 있습니다. 그렇다면 장바구니 클래스를 컴파일 할 때 제품에서 "기호를 찾을 수 없습니다"라는 메시지가 나타나는 이유는 무엇입니까? 도움말 plz! 와 타이"기호를 찾을 수 없습니다"이유는 무엇입니까?

Cart 클래스 :

package com.DownloadThis; 

import java.util.ArrayList; 

public class Cart { 

private ArrayList<Product> myCart; 

public Cart() { 
myCart = new ArrayList<Product>(); 
} 

public void addProduct(Product p) { 
myCart.add(p); 
} 

public float getTotal() { 
float totalPrice = 0; 
for(int i = 0; i < myCart.size(); i++) { 
    Object obj = myCart.get(i); 
    Product p = (Product)obj; 
    totalPrice = totalPrice + p.getPrice(); 
} 
return totalPrice; 
} 

public void addToCart(int product_id) { 


} 
} 

제품 클래스 :

package com.DownloadThis; 

import java.sql.*; 

public class Product { 

private String artist; 
private String album; 
private int year; 
private String genre; 
private float price; 
private String albumart; 
private String username; 
private String password; 

private Connection connection = null; 
private ResultSet rs = null; 
private Statement st = null; 

public Product() { 
} 

public Product(String artist, String album, int year, String genre, float price, String albumart) { 
this.artist = artist; 
this.album = album; 
this.year = year; 
this.genre = genre; 
this.price = price; 
this.albumart = albumart; 
} 


public String getArtist() { 
    return this.artist; 
} 

public void setArtist(String artist) { 
    this.artist = artist; 
} 

public String getAlbum() { 
    return this.album; 
} 

public void setAlbum(String album) { 
    this.album = album; 
} 

public int getYear() { 
    return this.year; 
} 

public void setYear(int year) { 
    this.year = year; 
} 

public String getGenre() { 
    return this.genre; 
} 

public void setGenre(String genre) { 
    this.genre = genre; 
} 

public float getPrice() { 
    return this.price; 
} 

public void setPrice(float price) { 
    this.price = price; 
} 

public String getAlbumart() { 
    return this.albumart; 
} 

public void setFilename(String albumart) { 
    this.albumart = albumart; 
} 

}

+0

전체 오류를 게시 할 수 있습니까? – kosa

+2

... 정확히 생산하는 라인과 함께 – Vlad

+0

커맨드 라인에서 컴파일 중입니까? 일식? – thatidiotguy

답변

2

컴파일하면 상위 폴더에 있어야 - 당신의 패키지로, 즉, com.DownloadThis, "com"폴더 위에 있어야합니다 (명령 줄에서 dir을 실행하면 결과에 com 폴더가 표시됩니다).

com 폴더에는 .class 파일을 포함해야하는 DownloadThis 폴더 (이름은 대소 문자를 구분 함)가 있어야합니다.

+0

아, 그게 문제라고 생각합니다! 감사! – Razz

0

"javac *"를 실행하여 ../com/DownloadThis/에서 두 파일을 직접 컴파일 할 수 있습니다.

관련 문제