Write a Java class CanOfCoke that represents information about cans of Coke. The following information is associated with each can:
• Whether or not the can has been opened
• The number of "sips" of drink remaining in it - initially this is 5 (when the can is full), and is 0 when the can has been emptied. 2 would indicate that 3 sips have been drunk.
3 1475
guys reply me soon,it is very urgent and i couldn.t get the output
Nepomuk 3,112
Recognized Expert Specialist
Hi kani313 and welcome to bytes.com!
That sounds like the kind of task you would get in a programming beginners class, so I'm assuming this is your homework? We won't do your homework for you but if you show us what you've done so far and tell us what's wrong with it, we'll be happy to help you fix it.
Generally speaking you will need two simple data types: a boolean, which saves boolean values (which are true and false) and some kind of number, e.g. an int which saves an integer (0, 1, -1, 2, -2, ...).
Your question is also not very clear. Is the user going to be typing how many sips that have been taken?
There is too much ambiguity in your question for anyone to go with, and referring to @Nepomuk's post, no one will simply write a class for you.
I will try to help you, simply. - boolean open = false;
-
int sip = 5;
-
-
If (open = false)
-
~WriteSomething "The can is unopened"
I'm going to leave the "sip" function up to you because I'm not sure how to handle it because of your lack of clarity in your OP. I think you know how to do it, just give it a try. If you fail, Google what you think you are doing wrong, and try it again.
What will happen (aside from your homework not being turned in on time) ? The computer will burst in flames and everyone will laugh? No. How else will you learn?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: vishal |
last post by:
hi
i am building aan application which will send mail to user when he
registers on my site and i am checking whther the email id is working
properly or not by sending his email and then cheking whether the email
was rebound or not.
i know something about how to send email in php using mail function but
not everything about sending email.
|
by: Siu |
last post by:
Hi,
in my ASP.NET (C#) application I would like to check in advance if a node
exist: my code is as follow:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(XML_FILENAME);
XmlNode nodeApplication = xmlDoc.SelectSingleNode(xmlPath);
Before launching the instruction xmlDoc.SelectSingoleNode(xmlPath), how
would like to check if my xmlPath exists in the Xml document... it is a soft
|
by: zimmy |
last post by:
Hi,
Is it possible to check whether ASP.NET is installed on a machine,
within a program that I'm writing in C#? And if it's installed, can I
check if it is enabled? How?
Thanks
|
by: Nuno Magalhaes |
last post by:
How to check for a closed http socket without losing any data? (MSDN
says to send something to server).
Somewhere in my code (after sending the http header in plain text) I'm
doing a loop with:
Loop:----------------
Socket.Receive //receive http data chunks
Socket.Send //'/r/n' data to check if connection is active
------------------------
The problem is that when connection is closed by the http server, the
send socket function...
|
by: Ros |
last post by:
There are 10 files in the folder. I wish to process all the files one
by one. But if the files are open or some processing is going on them
then I do not want to disturb that process. In that case I would
ignore processing that particular file and move to next file.
How can I check whether the file is open or not?
I tried os.stat and os.access but I am not getting the expected
results.
Also I checked in IO exceptions, IO error handler...
| |
by: Frinavale |
last post by:
Filtering user input is extremely important for web programming.
If input is left unfiltered users can input malicious code that can cripple your website.
This article will explain how to make sure that the user only submits a number to your .NET web application and also demonstrate how to add JavaScript to your ASPX pages. Upon popular demand, I have added a section that also covers how to use a validator control to check if a text box...
|
by: mathewgk80 |
last post by:
Hi all,
I would like to get the Javascript code to check the textbox contains only numeric values or numbers..
I am using asp.net and c#.net..
Please help me..
Regards,
Mathew
|
by: foolsmart2005 |
last post by:
There are 10 webpages on the host,
e.g. 001.html, 002.html, 003,html, 004.html, ......010.html
I want to check whether the page is the last page. How can I do.
In the index.html
-Go to last page,<---- I want to link this to the last
page(010.html). Can I do it? How? Thanks!
|
by: kavitachawoor |
last post by:
How to check popup window closed or with in that link button is clickedd or not.it mence-after displaying popup window if user close or click on link button with in the popup window the varible xyz should set to 1 value. it meance
if(popup.close==true)
{
xyz=1;
}
or
if(popup.linkclick==true)
|
by: divyakgowda |
last post by:
Hello everyone,
My problem is, i am uploading a zipped file and extracting the contents and saving in a directory.How can i check whether the uploading zipped file contains only .swf files inside, before or after extraction.Please help how can i do this? Its urgent.
Thanks,
amulyab
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |