2A
New Year's Eve is Dec 31, 2019.
Write a program HowLongIsIt
which will calculate how many days from today (whatever day the program is run) until New Year's Eve.
Chapter 2 Worked Example 1 from your text or in VitalSource if you are signed in gives you a Day
class and discusses how to use it. A copy of the Day
class itself is at the Codecheck URL below. You need to copy the class into a Bluej project along with the starter code.
Lesson 2 of the Horstmann videos also discusses the Day
object. Section 19: How Many Days gives an example of working with the Day object in code.
Create a class called HowLongIsIt
and copy in the starter code for the Codecheck URL below. Create a Day
class and copy that code from Codecheck link
Now in the main method, do the following:
Day
object representing the current day. Use the constructor that does not take any parameters, like this. new Day()
Day
object to a variable called today
. There is already a statement in the starter file to print the variable today
. Do not change it. Note that no matter when the application is run, the value in today
should be the current date. That means do not put any parameters in the parentheses for the Day constructorDay
object representing New Year's Eve and assign it to a variable.For the draft, just add code to the starter to define the variable today
and assign today's date to it. When you run the program, the date will be printed by the starter code.
2A draft:
2A final: (new URL Sep 2)
2B
Complete the class UsingStrings
class using String methods. Remember that all the String methods are accessors. They do not change the original String.
Complete the class by doing the following
You are given a word in the starter file and Codecheck will test with that word and with a different word. You do not need to worry about the second word. Codecheck will take care of that.
For the draft, just print the string length. The original word will be printed for you.
2C
Railroad crossings have a signal consisting of two circles. Frist one flashes red and then the other flashes red.
In this problem, you will write a class RailroadCrossingSignal
(name of class fixed Sep 4) to model a railroad crossing signal using the Ellipse and Rectangle classes from the Horstmann graphics package. Download and unzip the graphics package if you have not done so. The URL is in the syllabus area of Canvas.
Create a new Bluej project. Select Project->Import ... Navigate to the graphics folder you downloaded and add to your project. Be sure the folder you import contains the files directly and does not contain an extra folder. Your workbench should look similar to the one below - although your classes may be in a different configuration.
Create a class called RailroadCrossingSignal
in the project. Add a main method to the class. There is no starter file this time
Your drawing should follow these specifications. The code goes in the main method.
Final output:
For the draft create the left circle and fill it with red (Use Color.RED)