The contents of this file are for educational purposes.
In this file we include an interface called Shape. This interface declares a number of methods which must be implemented by its subclasses.
Download the repo using git or simply use the download link. Once you have the files on your local machine, you are free to use any Java IDE you choose or you can simply use the command line.
-
Create a github account, if you don't already have one.
-
If git is not already installed on your machine, download and install it.
-
Once git is installed, navigate using a terminal or putty to where you want to store this project on your computer.
-
Click on the
Clone or Downloadbutton for this repo. Be sure to click onUse HTTPlink and copy url.Note: Setting up ssh authentication when you create your Github account, will allow you to use the default ssh method
-
Then in the terminal, run the following to download this project's files:
git clone https://github.com/tech-talent-south/java-shape-example.git
Note: For any other project you would substitute the url here with the url you copied in the previous step.
-
Setup your project in your IDE of choice.
-
Skip to exercises below.
Preq: Using a terminal (putty from windows), navigate to your projects directory.
To compile all the Java files on the command line type the following command:
> javac *.javaThen to run your newly compiled code type:
> java Triangleor
> java Square-
Remove area class from Triangle class and recompile.
What happened and why?
-
Add a method to square to calculate the
circumferenceof a square and ensure that it prints the circumference when ran. Method should take 1 argument -
Create another method called
circumferencethat takes two arguments, length and width and computes the circumference. -
Convert the Shape class into an abstract class. Ensure it runs successfully.