Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Peak.java
- class Peak {
- String mountName;
- boolean bassList;
- boolean messnerList;
- double elevationMt;
- String country;
- String range;
- String continent;
- int firstAscent;
- }
- SevenSummits.java
- public class SevenSummits {
- public static void main(String[] args) {
- //https://en.wikipedia.org/wiki/Seven_Summits#The_Bass_and_Messner_lists
- //Tworzenie zmiennej typu obiektowego (deklaracja i inicjalizacja)
- Peak mountKosciuszko = new Peak(); //mountKosciuszko jest referencja na obiekt typu Peak
- Peak puncakJaya = new Peak();
- Peak mountVinson = new Peak();
- Peak mountElbrus = new Peak();
- Peak kilimanjaro = new Peak();
- Peak denali = new Peak();
- Peak aconcagua = new Peak();
- Peak mountEverest = new Peak();
- mountKosciuszko.mountName = "Mount Kosciuszko";
- mountKosciuszko.bassList = true;
- mountKosciuszko.messnerList = false;
- mountKosciuszko.elevationMt = 2.228;
- mountKosciuszko.range = "Great Dividing Range";
- mountKosciuszko.continent = "Australia";
- mountKosciuszko.country = "Australia";
- mountKosciuszko.firstAscent = 1840;
- puncakJaya.mountName = "Puncak Jaya" ;
- puncakJaya.bassList = false;
- puncakJaya.messnerList = true;
- puncakJaya.elevationMt = 4.884;
- puncakJaya.range = "Sudirman Range";
- puncakJaya.continent = "Australasia";
- puncakJaya.country = "Indonesia";
- puncakJaya.firstAscent = 1962;
- mountVinson.mountName = "Mount Vinson" ;
- mountVinson.bassList = true;
- mountVinson.messnerList = true;
- mountVinson.elevationMt = 4.892;
- mountVinson.range = "Sentinel Range";
- mountVinson.continent = "Antarctica";
- mountVinson.country = "-";
- mountVinson.firstAscent = 1966;
- mountElbrus.mountName = "Mount Elbrus" ;
- mountElbrus.bassList = true;
- mountElbrus.messnerList = true;
- mountElbrus.elevationMt = 5.642;
- mountElbrus.range = "Caucasus Mountains";
- mountElbrus.continent = "Europe";
- mountElbrus.country = "Russia";
- mountElbrus.firstAscent = 1840;
- kilimanjaro.mountName = "Kilimanjaro" ;
- kilimanjaro.bassList = true;
- kilimanjaro.messnerList = true;
- kilimanjaro.elevationMt = 5.895;
- kilimanjaro.range = "-";
- kilimanjaro.continent = "Africa";
- kilimanjaro.country = "Tanzania";
- kilimanjaro.firstAscent = 1889;
- denali.mountName = "Denali" ;
- denali.bassList = true;
- denali.messnerList = true;
- denali.elevationMt = 6.194;
- denali.range = "Alaska Range";
- denali.continent = "North America";
- denali.country = "United States";
- denali.firstAscent = 1913;
- aconcagua.mountName = "Aconcagua" ;
- aconcagua.bassList = true;
- aconcagua.messnerList = true;
- aconcagua.elevationMt = 6.961;
- aconcagua.range = "Andes";
- aconcagua.continent = "South America";
- aconcagua.country = "Argentina";
- aconcagua.firstAscent = 1897;
- mountEverest.mountName = "Mount Everest" ;
- mountEverest.bassList = true;
- mountEverest.messnerList = true;
- mountEverest.elevationMt = 8848;
- mountEverest.range = "Himalaya";
- mountEverest.continent = "Asia";
- mountEverest.country = "China/Nepal";
- mountEverest.firstAscent = 1953;
- String mountKosciuszkoInfo = "1. " + mountKosciuszko.mountName
- + ", Bass List: " + mountKosciuszko.bassList
- + ", Messner List: " + mountKosciuszko.messnerList
- + ", Elevation (Mt): " + mountKosciuszko.elevationMt
- + ", Range: " + mountKosciuszko.range
- + ", Continent: " + mountKosciuszko.continent
- + ", Country: " + mountKosciuszko.country
- + ", First Ascent: " + mountKosciuszko.firstAscent;
- String puncakJayaInfo = "2. " + puncakJaya.mountName
- + ", Bass List: " + puncakJaya.bassList
- + ", Messner List: " + puncakJaya.messnerList
- + ", Elevation (Mt): " + puncakJaya.elevationMt
- + ", Range: " + puncakJaya.range
- + ", Continent: " + puncakJaya.continent
- + ", Country: " + puncakJaya.country
- + ", First Ascent: " + puncakJaya.firstAscent;
- String mountVinsonInfo = "3. " + mountVinson.mountName
- + ", Bass List: " + mountVinson.bassList
- + ", Messner List: " + mountVinson.messnerList
- + ", Elevation (Mt): " + mountVinson.elevationMt
- + ", Range: " + mountVinson.range
- + ", Continent: " + mountVinson.continent
- + ", Country: " + mountVinson.country
- + ", First Ascent: " + mountVinson.firstAscent;
- String mountElbrusInfo ="4. " + mountElbrus.mountName
- + ", Bass List: " + mountElbrus.bassList
- + ", Messner List: " + mountElbrus.messnerList
- + ", Elevation (Mt): " + mountElbrus.elevationMt
- + ", Range: " + mountElbrus.range
- + ", Continent: " + mountElbrus.continent
- + ", Country: " + mountElbrus.country
- + ", First Ascent: " + mountElbrus.firstAscent;
- String kilimanjaroInfo = "5. " + kilimanjaro.mountName
- + ", Bass List: " + kilimanjaro.bassList
- + ", Messner List: " + kilimanjaro.messnerList
- + ", Elevation (Mt): " + kilimanjaro.elevationMt
- + ", Range: " + kilimanjaro.range
- + ", Continent: " + kilimanjaro.continent
- + ", Country: " + kilimanjaro.country
- + ", First Ascent: " + kilimanjaro.firstAscent;
- String denaliInfo = "6. " + denali.mountName
- + ", Bass List: " + denali.bassList
- + ", Messner List: " + denali.messnerList
- + ", Elevation (Mt): " + denali.elevationMt
- + ", Range: " + denali.range
- + ", Continent: " + denali.continent
- + ", Country: " + denali.country
- + ", First Ascent: " + denali.firstAscent;
- String aconcaguaInfo = "7. " + aconcagua.mountName
- + ", Bass List: " + aconcagua.bassList
- + ", Messner List: " + aconcagua.messnerList
- + ", Elevation (Mt): " + aconcagua.elevationMt
- + ", Range: " + aconcagua.range
- + ", Continent: " + aconcagua.continent
- + ", Country: " + aconcagua.country
- + ", First Ascent: " + aconcagua.firstAscent;
- String mountEverestInfo = "8. " + mountEverest.mountName
- + ", Bass List: " + mountEverest.bassList
- + ", Messner List: " + mountEverest.messnerList
- + ", Elevation (Mt): " + mountEverest.elevationMt
- + ", Range: " + mountEverest.range
- + ", Continent: " + mountEverest.continent
- + ", Country: " + mountEverest.country
- + ", First Ascent: " + mountEverest.firstAscent;
- System.out.println("Seven Summit List: ");
- System.out.println(mountKosciuszkoInfo);
- System.out.println(puncakJayaInfo);
- System.out.println(mountVinsonInfo);
- System.out.println(mountElbrusInfo);
- System.out.println(kilimanjaroInfo);
- System.out.println(denaliInfo);
- System.out.println(aconcaguaInfo);
- System.out.println(mountEverestInfo);
- System.out.println("Czy Mt Elbus jest wyższy od Mt Everest?: "
- + (mountElbrus.elevationMt>mountEverest.elevationMt));
- System.out.println("Czy Mt Elbus jest niższy od Mt Everest?: "
- + (mountElbrus.elevationMt<mountEverest.elevationMt));
- System.out.println("Czy zmienna mountElbrus jest typu Peak?");
- boolean isPeak = mountElbrus instanceof Peak;
- System.out.println(isPeak);
- // never ending CODE :D but it WORKS
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement