java - 即使声明了类,在java中也找不到错误
问题描述
public class Video {
String videoName;
boolean checkout;
int rating;
public Video(){
}
public Video(String name)
{
videoName=name;
}
public String getName()
{
return videoName;
}
public void doCheckout()
{
System.err.println("Video "+'"'+ getName()+'"' +" checked out successfully.");
}
public void doReturn()
{
checkout=true;
System.err.println("Video "+'"'+ getName()+'"' +" returned successfully.");
}
public void receiveRating(int rating)
{
this.rating=rating;
}
public int getRating()
{
return rating;
}
public boolean getCheckout()
{
return checkout;
}
}
public class VideoStore {
Video store[];
public VideoStore() {
store=new Video[5];
}
public void addVideo(String name)
{
store[0]=new Video(name);
System.err.println("Video "+'"'+store[0].getName()+'"'+" added successfully");
}
public void doCheckout(String name)
{
if(store[0].videoName.equals(name))
{
store[0].doCheckout();
}
}
public void doReturn(String name)
{
if(store[0].videoName.equals(name))
{
store[0].doReturn();
}
}
public void receiveRating(String name, int rating) {
if(store[0].videoName.equals(name))
{
store[0].receiveRating(rating);
}
System.err.println("Rating "+'"'+store[0].getRating()+'"'+" has been mapped to the Video ''"+store[0].getName()+'"');
}
public void listInventory() {
System.out.println("------------------------------------------");
System.out.println("Video Name | Checkout Status | Rating");
System.out.println(store[0].getName()+"|" +store[0].getCheckout()+ "|"+ store[0].getRating());
System.out.println("------------------------------------------");
}
}
import java.util.Scanner;
public class VideoLaucher {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int choice;
VideoStore videoStore=new VideoStore();
do {
System.out.println("MAIN MENU \n=========");
System.out.println("1. Add Videos:");
System.out.println("2. Check Out Video:");
System.out.println("3. Return Video:");
System.out.println("4. Receive Rating:");
System.out.println("5. List Inventory:");
System.out.println("6. Exit:");
System.out.print("Enter your choice(1..6): ");
choice=input.nextInt();
switch (choice) {
case 1:
System.out.println("Enter the name of the video you want to add: ");
videoStore.addVideo(input.next());
break;
case 2:
System.out.print("Enter the name of the video you want to check out: ");
videoStore.doCheckout(input.next());
break;
case 3:
System.out.print("Enter the name of the video you want to Return:");
videoStore.doReturn(input.next());;
break;
case 4:
System.out.println("Enter the name of the video you want to Rate: ");
videoStore.receiveRating(input.next(), input.nextInt());
break;
case 5:
videoStore.listInventory();
break;
case 6:
System.err.println("Enter ...!! Thanks for using the application");
System.exit(1);
break;
}
}while(!(choice==6));
input.close();
}
}
当我尝试编译时VideoStore.java
,VideoLaucher.java
我收到以下错误
[neo@EDI Practice]$ javac VideoStore.java
VideoStore.java:5: error: cannot find symbol
Video store[];
^
symbol: class Video
location: class VideoStore
VideoStore.java:8: error: cannot find symbol
store=new Video[5];
^
symbol: class Video
location: class VideoStore
VideoStore.java:13: error: cannot find symbol
store[0]=new Video(name);
^
symbol: class Video
location: class VideoStore
3 errors
解决方案
推荐阅读
- sql - 带有整数和字符串的 Django Concat 列
- sql-server - 如何将所有模式从一个数据库复制到另一个数据库(在运行时创建)?
- javascript - 使用 map 和 redux 时子道具触发重新渲染
- java - Oracle查询未返回正确数量的结果
- forms - Bootstrap 4 & Phpmailer 表单上传文件
- matlab - 当变量矩阵中存在常数时,在MATLAB上求解方程组?
- python - 基于熊猫数据框中的值的彩色编码表格图
- android - 面临错误...通过以特定格式定义 json 来生成 android 动态表单
- mysql - 实时生产服务器旁边的开发 SQL
- javascript - css 中的关键帧无法使用 javascript 正常工作