• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Capacity of string array confusion / need clarity  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting code writer's block and I cannot think straight on how to structure a certain piece of code in java I am getting my self confused and would like some guidance, please . I want to pass a variable from one method to another such as a user has selected an option from an array list "select " variable and I want to compare the select variable with an array list capacity which will show that the select array list option " the selected lesson capacity is full in the evening "  " but not in the morning  would you like to book this lesson instead "

so what I have done is code up name string arrays in a customer class one array list has 20 customer names   and less than 20 customers (  please do not pay any notice to the duplicate customer names I am still editing )

Here is  the lesson  class code

package fitnessclassapp;







within the main controller class where I would hard code the functionality, I have made the capacity method where I would show the capacity for user input with is the " selected lesson"  the " select" variable.    So if the user selects array choice number 1 which is "Zumba " I want the capacity method to be able to show " the Zumba afternoon lesson is full" and the " morning lesson is available "   by comparing the two string arrays in the class method. but I am experiencing a block please help me I would appreciate some basic guidance, please

what I have done so far in the main controller capacity method
);   // created  an object called array of the customer class and called the afterNoon array liparameterassed the paramter


the capacity code

String [] lessonCust = new String [20];
array.afterNoon(lessonCust);  


 This line has an error for the "array " object stating package array does not exist, I had this error before within another method but that was due to me trying to set two constructors. now I do not know what is going on please help me.  The customer class is above
     
   
   
   
       

 
 
Bartender
Posts: 5303
55
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These two methods have a few problems. A "Customer" represents a single person and shouldn't have an array of after noon people, nor a morning array of people. These two methods don't belong in the Customer class. Then, you are passing in arrays to the methods but nowhere are you using the arrays.  The methods also create and initialize their own arrays and then they get thrown away when the methods return.
 
Marshal
Posts: 62231
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really want setXXX() methods for the customers? Are they going to change age and name?
Why are you using chars for membership type? Try an enumerated type/enum instead.You most probably will want to change membership categories from time to time, if for example your customers pay extra for PREMIUM.
 
Campbell Ritchie
Marshal
Posts: 62231
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have quite a lot of spelling errors in those two methods Carey quoted. Also, don't start method names with CapitalLetters (Morning). Did you mean to call the array in the morning method evening? Are the duplicated names simply there to show how the method works?
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!