Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Cat { /* Instance variables: states of Cat */ String name; int age; String color; String breed; /* Instance methods: behaviors of Cat

public class Cat { /* Instance variables: states of Cat */ String name; int age; String color; String breed;

/* Instance methods: behaviors of Cat */ void sleep(){ System.out.println("Sleeping"); } void play(){ System.out.println("Playing"); } void feed(){ System.out.println("Eating"); }

}

public class Main { public static void main(String[] args) { Cat thor = new Cat(); Cat rambo = new Cat(); } }

public class Main {

public static void main(String[] args) { /* Creating objects */ Cat thor = new Cat(); Cat rambo = new Cat();

/* Defining Thor cat */ thor.name = "Thor"; thor.age = 3; thor.breed = "Russian Blue"; thor.color = "Brown";

thor.sleep();

/* Defining Rambo cat */ rambo.name = "Rambo"; rambo.age = 4; rambo.breed = "Maine Coon"; rambo.color = "Brown";

rambo.play(); }

} public class Album { public String name; public String artist; public double price; public int numberOfCopies; public void sellCopies(){ if(numberOfCopies > 0){ numberOfCopies--; System.out.println("One album has sold!"); } else{ System.out.println("No more albums available!"); } } public void orderCopies(int num){ numberOfCopies += num; } }

public class StockKeeper { public String name; public StockKeeper(String name){ this.name = name; } public void manageAlbum(Album album, String name, String artist, double price, int numberOfCopies){ /* Defining states and behaviors for album */ album.name = name; album.artist = artist; album.price = price; album.numberOfCopies = numberOfCopies;

/* Printing album details */ System.out.println("Album managed by :"+ this.name); System.out.println("Album details::::::::::"); System.out.println("Album name : " + album.name); System.out.println("Album artist : " + album.artist); System.out.println("Album price : " + album.price); System.out.println("Album number of copies : " + album.numberOfCopies); } } Main class: public class Main { public static void main(String[] args) { StockKeeper johnDoe = new StockKeeper("John Doe"); /* Stock keeper creates album and assigns negative values for price and number of copies available */ johnDoe.manageAlbum(new Album(), "Slippery When Wet", "Bon Jovi", -1000.00, -50); } } } }

As you may see, I have to run this code in Java but in the command Main class: (it is in bold), there is a mistake and I can not run it.

Could you please help me? I need the code to work it's important.

I am leaving the code picture to see it better.

image text in transcribed

V Execute Mode, Version, Inputs & Arguments .. Execute 6 4 Result CPU Time: sec(s), Memory: kilobyte(s) compiled and executed in 1.374 sec(s) Cat.java:108: error: class, interface, enum, or record expected Main class: 91 */ 92 album.name = name; 93 album artist = artist; 94 albue.price - price; 95 album.number of Copies = numberOfCopies; 96 97- / 98 Printing album details 99 "/ lee System.out.println("Album managed by :"+ this.name); 101 System.out.printin("Album details::::::::::"); 102 System.out.println("Album name: " + album.name); + ) 103 System.out.println("Album artist : " + album.artist); 104 System.out.println("Album price : " + album.price); + ; 105 System.out.println("Album number of copies + albunt. numberofcopies); 106 ) 107 108 Hain class: 109 - public class Main { 110- public static void main(String[] args) { 111 StockKeeper john Doe = new StockKeeper("John Doe"); 112 - 113 Stock keeper creates album and assigns negative values for price and number of copies availabl 114 / / 115 johnDoe. nanageAlbum(new Album(), "Slippery When Wet", "son Jovi", -1000.00, -50); 117 A Cat.java:18: error: expected Main class: 2 errors 116 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago